blob: c329d264ed480891c737179d2afcf8a14ca78137 [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",
Jakob Vukalovic4c1edbe2023-04-17 19:10:57 +010015 "cpu_feat_hafdbs",
Pierre-Clément Tosie8726e42022-10-17 13:35:27 +010016 ],
Andrew Walbranf2594882022-03-15 17:32:53 +000017 rustlibs: [
Pierre-Clément Tosia8a4a202022-11-03 14:16:46 +000018 "libaarch64_paging",
Pierre-Clément Tosi90cd4f12023-02-17 11:19:56 +000019 "libbssl_ffi_nostd",
Pierre-Clément Tosifc531152022-10-20 12:22:23 +010020 "libbuddy_system_allocator",
Alan Stokesd1ee63e2023-04-24 16:17:39 +010021 "libciborium_nostd",
22 "libciborium_io_nostd",
Alice Wangcb9d2f92023-02-06 10:29:00 +000023 "libdiced_open_dice_nostd",
Andrew Walbran730375d2022-12-21 14:04:34 +000024 "libfdtpci",
Alice Wang0bdc3f62023-03-15 10:46:12 +000025 "libhyp",
Pierre-Clément Tosia0934c12022-11-25 20:54:11 +000026 "liblibfdt",
Pierre-Clément Tosi37105a62022-10-18 12:21:48 +010027 "liblog_rust_nostd",
Andrew Walbranb398fc82023-01-24 14:45:46 +000028 "libonce_cell_nostd",
Andrew Walbran9afab672023-04-17 14:26:23 +000029 "libpsci",
Pierre-Clément Tosi2d652982023-01-09 19:30:17 +000030 "libpvmfw_avb_nostd",
Pierre-Clément Tosi4ef75222022-10-26 17:40:50 +010031 "libpvmfw_embedded_key",
Jiyong Park216793e2023-02-25 02:15:44 +090032 "libpvmfw_fdt_template",
Pierre-Clément Tosi1cc5eb72023-02-02 11:09:18 +000033 "libstatic_assertions",
Pierre-Clément Tosi328dfb62022-11-25 18:20:42 +000034 "libtinyvec_nostd",
Pierre-Clément Tosi1cc5eb72023-02-02 11:09:18 +000035 "libuuid_nostd",
Andrew Walbrand1d03182022-12-09 18:20:01 +000036 "libvirtio_drivers",
Andrew Walbrandd74b902022-04-14 16:12:50 +000037 "libvmbase",
Alan Stokesa0e42962023-04-14 17:59:50 +010038 "libzerocopy_nostd",
Pierre-Clément Tosi8383c542022-11-01 14:07:29 +000039 "libzeroize_nostd",
Jakob Vukalovic85a00d72023-04-20 09:51:10 +010040 "libspin_nostd",
Andrew Walbranf2594882022-03-15 17:32:53 +000041 ],
Andrew Walbran68a8c162022-03-07 15:38:42 +000042}
Andrew Walbran15068b02022-03-22 15:57:34 +000043
Alice Wang1c7e0eb2023-04-11 17:03:42 +000044// Generates an empty file.
45genrule {
46 name: "empty_file",
47 out: ["empty_file"],
48 cmd: "touch $(out)",
49}
50
Jiyong Parkc5d2ef22023-04-11 01:23:46 +090051rust_test {
52 name: "libpvmfw.bootargs.test",
53 host_supported: true,
54 // For now, only bootargs.rs is written to be conditionally compiled with std.
55 srcs: ["src/bootargs.rs"],
56 test_suites: ["general-tests"],
57 test_options: {
58 unit_test: true,
59 },
60 rustlibs: [
61 "libzeroize",
62 ],
63}
64
Andrew Walbran15068b02022-03-22 15:57:34 +000065cc_binary {
Pierre-Clément Tosib1300352022-09-09 11:01:06 +010066 name: "pvmfw",
David Brazdil30a7f082022-07-07 15:30:14 +010067 defaults: ["vmbase_elf_defaults"],
Andrew Walbran15068b02022-03-22 15:57:34 +000068 srcs: [
Andrew Walbran267f6c12022-03-24 11:26:36 +000069 "idmap.S",
Andrew Walbran15068b02022-03-22 15:57:34 +000070 ],
71 static_libs: [
72 "libpvmfw",
73 ],
Andrew Walbrana5b7af52022-07-06 15:06:20 +000074 linker_scripts: [
75 "image.ld",
76 ":vmbase_sections",
77 ],
Jiyong Park17b8d752022-12-16 14:36:24 +090078 // `installable: false` is inherited from vmbase_elf_defaults, and that
79 // hides this module from Make, which makes it impossible for the Make world
80 // to place the unstripped binary to the symbols directory. Marking back as
81 // installable exposes this module to the Make world again. Note that this
82 // module (pvmfw) still is NOT installed to any of the filesystem images. It
83 // is fed into pvmfw_bin and then into pvmfw_img to become a standalone
84 // partition image. This is just to package the unstripped file into the
85 // symbols zip file for debugging purpose.
86 installable: true,
Nikita Ioffe831b08b2023-03-13 21:18:40 +000087 native_coverage: false,
Andrew Walbran15068b02022-03-22 15:57:34 +000088}
David Brazdil05d4e072022-04-25 14:47:06 +010089
90raw_binary {
Pierre-Clément Tosib1300352022-09-09 11:01:06 +010091 name: "pvmfw_bin",
92 stem: "pvmfw.bin",
93 src: ":pvmfw",
David Brazdil05d4e072022-04-25 14:47:06 +010094 enabled: false,
95 target: {
96 android_arm64: {
97 enabled: true,
98 },
99 },
100}
David Brazdilac216b52022-04-25 15:07:22 +0100101
Jaewan Kim2cf6f392023-02-10 01:35:47 +0900102// Provide pvmfw.bin binary regardless of the architecture for building test.
103// Note that skipping tests on unsupported device is easy
104// while configuring server configuration to make such tests to run on working
105// devices.
106prebuilt_etc {
107 name: "pvmfw_test",
108 filename: "pvmfw_test.bin",
109 target: {
110 android_arm64: {
111 src: ":pvmfw_bin",
112 },
113 },
Alice Wang1c7e0eb2023-04-11 17:03:42 +0000114 src: ":empty_file",
Jaewan Kim2cf6f392023-02-10 01:35:47 +0900115 installable: false,
116}
117
Pierre-Clément Tosib5771c02022-09-06 16:01:35 +0100118prebuilt_etc {
Pierre-Clément Tosi6ec2ae22022-10-26 15:14:45 +0100119 name: "pvmfw_embedded_key",
120 src: ":avb_testkey_rsa4096_pub_bin",
121 installable: false,
122}
123
Pierre-Clément Tosi4ef75222022-10-26 17:40:50 +0100124genrule {
125 name: "pvmfw_embedded_key_rs",
126 srcs: [":pvmfw_embedded_key"],
127 out: ["lib.rs"],
128 cmd: "(" +
129 " echo '#![no_std]';" +
130 " echo '#![allow(missing_docs)]';" +
131 " echo 'pub const PUBLIC_KEY: &[u8] = &[';" +
132 " xxd -i < $(in);" +
133 " echo '];';" +
134 ") > $(out)",
135}
136
137rust_library_rlib {
138 name: "libpvmfw_embedded_key",
139 defaults: ["vmbase_ffi_defaults"],
140 prefer_rlib: true,
141 srcs: [":pvmfw_embedded_key_rs"],
142 crate_name: "pvmfw_embedded_key",
143 apex_available: ["com.android.virt"],
144}
145
Pierre-Clément Tosi6ec2ae22022-10-26 15:14:45 +0100146prebuilt_etc {
Pierre-Clément Tosib5771c02022-09-06 16:01:35 +0100147 name: "pvmfw_sign_key",
148 src: ":avb_testkey_rsa4096",
149 installable: false,
150}
151
Jiyong Park216793e2023-02-25 02:15:44 +0900152// platform.dts is passed to clang for macro preprocessing, and then compiled to dtbo using dtc.
153// The raw content of the dtbo file is then written as a Rust byte array.
154genrule {
155 name: "pvmfw_fdt_template_rs",
156 srcs: [
157 "platform.dts",
158 ":arm_dt_bindings_headers", // implicit dependency
159 ],
160 out: ["lib.rs"],
161 tools: ["dtc"],
Yi Kong8ba2eb42023-05-19 20:04:16 +0000162 cmd: "prebuilts/clang/host/linux-x86/clang-r487747c/bin/clang " + // UGLY!!!
Jiyong Park216793e2023-02-25 02:15:44 +0900163 "-E -P -x assembler-with-cpp -I external/arm-trusted-firmware/include " +
164 "-o $(genDir)/preprocessed.dts $(location platform.dts) && " +
165 "$(location dtc) -I dts -O dtb -o $(genDir)/compiled.dtbo $(genDir)/preprocessed.dts && " +
166 "(" +
167 " echo '#![no_std]';" +
168 " echo '#![allow(missing_docs)]';" +
169 " echo 'pub const RAW: &[u8] = &[';" +
170 " xxd -i < $(genDir)/compiled.dtbo;" +
171 " echo '];';" +
172 ") > $(out)",
173}
174
175rust_library_rlib {
176 name: "libpvmfw_fdt_template",
177 defaults: ["vmbase_ffi_defaults"],
178 prefer_rlib: true,
179 srcs: [":pvmfw_fdt_template_rs"],
180 crate_name: "pvmfw_fdt_template",
181}
182
David Brazdilac216b52022-04-25 15:07:22 +0100183bootimg {
184 name: "pvmfw_img",
185 stem: "pvmfw.img",
186 kernel_prebuilt: ":pvmfw_bin",
187 header_version: "3",
188 partition_name: "pvmfw",
189 enabled: false,
190 target: {
191 android_arm64: {
192 enabled: true,
193 },
194 },
Pierre-Clément Tosib5771c02022-09-06 16:01:35 +0100195 use_avb: true,
196 avb_private_key: ":pvmfw_sign_key",
David Brazdilac216b52022-04-25 15:07:22 +0100197}