blob: 4254ecc8e36841b0c0886302654237f7aa6e4c16 [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",
Pierre-Clément Tosie8726e42022-10-17 13:35:27 +010011 features: [
12 "legacy",
13 ],
Andrew Walbranf2594882022-03-15 17:32:53 +000014 rustlibs: [
Pierre-Clément Tosia8a4a202022-11-03 14:16:46 +000015 "libaarch64_paging",
Pierre-Clément Tosi90cd4f12023-02-17 11:19:56 +000016 "libbssl_ffi_nostd",
Pierre-Clément Tosifc531152022-10-20 12:22:23 +010017 "libbuddy_system_allocator",
Alice Wangcb9d2f92023-02-06 10:29:00 +000018 "libdiced_open_dice_nostd",
Andrew Walbran730375d2022-12-21 14:04:34 +000019 "libfdtpci",
Pierre-Clément Tosia0934c12022-11-25 20:54:11 +000020 "liblibfdt",
Pierre-Clément Tosi37105a62022-10-18 12:21:48 +010021 "liblog_rust_nostd",
Andrew Walbranb398fc82023-01-24 14:45:46 +000022 "libonce_cell_nostd",
Alice Wanga516a612023-04-12 07:31:14 +000023 "libpsci",
Pierre-Clément Tosi2d652982023-01-09 19:30:17 +000024 "libpvmfw_avb_nostd",
Pierre-Clément Tosi4ef75222022-10-26 17:40:50 +010025 "libpvmfw_embedded_key",
Jiyong Park216793e2023-02-25 02:15:44 +090026 "libpvmfw_fdt_template",
Pierre-Clément Tosi1cc5eb72023-02-02 11:09:18 +000027 "libstatic_assertions",
Pierre-Clément Tosi328dfb62022-11-25 18:20:42 +000028 "libtinyvec_nostd",
Pierre-Clément Tosi1cc5eb72023-02-02 11:09:18 +000029 "libuuid_nostd",
Andrew Walbrand1d03182022-12-09 18:20:01 +000030 "libvirtio_drivers",
Andrew Walbrandd74b902022-04-14 16:12:50 +000031 "libvmbase",
Pierre-Clément Tosi8383c542022-11-01 14:07:29 +000032 "libzeroize_nostd",
Andrew Walbranf2594882022-03-15 17:32:53 +000033 ],
Andrew Walbran68a8c162022-03-07 15:38:42 +000034}
Andrew Walbran15068b02022-03-22 15:57:34 +000035
36cc_binary {
Pierre-Clément Tosib1300352022-09-09 11:01:06 +010037 name: "pvmfw",
David Brazdil30a7f082022-07-07 15:30:14 +010038 defaults: ["vmbase_elf_defaults"],
Andrew Walbran15068b02022-03-22 15:57:34 +000039 srcs: [
Andrew Walbran267f6c12022-03-24 11:26:36 +000040 "idmap.S",
Andrew Walbran15068b02022-03-22 15:57:34 +000041 ],
42 static_libs: [
43 "libpvmfw",
44 ],
Andrew Walbrana5b7af52022-07-06 15:06:20 +000045 linker_scripts: [
46 "image.ld",
47 ":vmbase_sections",
48 ],
Jiyong Park17b8d752022-12-16 14:36:24 +090049 // `installable: false` is inherited from vmbase_elf_defaults, and that
50 // hides this module from Make, which makes it impossible for the Make world
51 // to place the unstripped binary to the symbols directory. Marking back as
52 // installable exposes this module to the Make world again. Note that this
53 // module (pvmfw) still is NOT installed to any of the filesystem images. It
54 // is fed into pvmfw_bin and then into pvmfw_img to become a standalone
55 // partition image. This is just to package the unstripped file into the
56 // symbols zip file for debugging purpose.
57 installable: true,
Nikita Ioffe831b08b2023-03-13 21:18:40 +000058 native_coverage: false,
Andrew Walbran15068b02022-03-22 15:57:34 +000059}
David Brazdil05d4e072022-04-25 14:47:06 +010060
61raw_binary {
Pierre-Clément Tosib1300352022-09-09 11:01:06 +010062 name: "pvmfw_bin",
63 stem: "pvmfw.bin",
64 src: ":pvmfw",
David Brazdil05d4e072022-04-25 14:47:06 +010065 enabled: false,
66 target: {
67 android_arm64: {
68 enabled: true,
69 },
70 },
71}
David Brazdilac216b52022-04-25 15:07:22 +010072
Jaewan Kim2cf6f392023-02-10 01:35:47 +090073// Provide pvmfw.bin binary regardless of the architecture for building test.
74// Note that skipping tests on unsupported device is easy
75// while configuring server configuration to make such tests to run on working
76// devices.
77prebuilt_etc {
78 name: "pvmfw_test",
79 filename: "pvmfw_test.bin",
80 target: {
81 android_arm64: {
82 src: ":pvmfw_bin",
83 },
84 },
85 src: "empty_file",
86 installable: false,
87}
88
Pierre-Clément Tosib5771c02022-09-06 16:01:35 +010089prebuilt_etc {
Pierre-Clément Tosi6ec2ae22022-10-26 15:14:45 +010090 name: "pvmfw_embedded_key",
91 src: ":avb_testkey_rsa4096_pub_bin",
92 installable: false,
93}
94
Pierre-Clément Tosi4ef75222022-10-26 17:40:50 +010095genrule {
96 name: "pvmfw_embedded_key_rs",
97 srcs: [":pvmfw_embedded_key"],
98 out: ["lib.rs"],
99 cmd: "(" +
100 " echo '#![no_std]';" +
101 " echo '#![allow(missing_docs)]';" +
102 " echo 'pub const PUBLIC_KEY: &[u8] = &[';" +
103 " xxd -i < $(in);" +
104 " echo '];';" +
105 ") > $(out)",
106}
107
108rust_library_rlib {
109 name: "libpvmfw_embedded_key",
110 defaults: ["vmbase_ffi_defaults"],
111 prefer_rlib: true,
112 srcs: [":pvmfw_embedded_key_rs"],
113 crate_name: "pvmfw_embedded_key",
114 apex_available: ["com.android.virt"],
115}
116
Pierre-Clément Tosi6ec2ae22022-10-26 15:14:45 +0100117prebuilt_etc {
Pierre-Clément Tosib5771c02022-09-06 16:01:35 +0100118 name: "pvmfw_sign_key",
119 src: ":avb_testkey_rsa4096",
120 installable: false,
121}
122
Jiyong Park216793e2023-02-25 02:15:44 +0900123// platform.dts is passed to clang for macro preprocessing, and then compiled to dtbo using dtc.
124// The raw content of the dtbo file is then written as a Rust byte array.
125genrule {
126 name: "pvmfw_fdt_template_rs",
127 srcs: [
128 "platform.dts",
129 ":arm_dt_bindings_headers", // implicit dependency
130 ],
131 out: ["lib.rs"],
132 tools: ["dtc"],
133 cmd: "prebuilts/clang/host/linux-x86/clang-r487747/bin/clang " + // UGLY!!!
134 "-E -P -x assembler-with-cpp -I external/arm-trusted-firmware/include " +
135 "-o $(genDir)/preprocessed.dts $(location platform.dts) && " +
136 "$(location dtc) -I dts -O dtb -o $(genDir)/compiled.dtbo $(genDir)/preprocessed.dts && " +
137 "(" +
138 " echo '#![no_std]';" +
139 " echo '#![allow(missing_docs)]';" +
140 " echo 'pub const RAW: &[u8] = &[';" +
141 " xxd -i < $(genDir)/compiled.dtbo;" +
142 " echo '];';" +
143 ") > $(out)",
144}
145
146rust_library_rlib {
147 name: "libpvmfw_fdt_template",
148 defaults: ["vmbase_ffi_defaults"],
149 prefer_rlib: true,
150 srcs: [":pvmfw_fdt_template_rs"],
151 crate_name: "pvmfw_fdt_template",
152}
153
David Brazdilac216b52022-04-25 15:07:22 +0100154bootimg {
155 name: "pvmfw_img",
156 stem: "pvmfw.img",
157 kernel_prebuilt: ":pvmfw_bin",
158 header_version: "3",
159 partition_name: "pvmfw",
160 enabled: false,
161 target: {
162 android_arm64: {
163 enabled: true,
164 },
165 },
Pierre-Clément Tosib5771c02022-09-06 16:01:35 +0100166 use_avb: true,
167 avb_private_key: ":pvmfw_sign_key",
David Brazdilac216b52022-04-25 15:07:22 +0100168}