Bob Badour | e8af284 | 2022-04-07 10:44:22 -0700 | [diff] [blame] | 1 | package { |
| 2 | default_applicable_licenses: ["Android-Apache-2.0"], |
| 3 | } |
| 4 | |
Andrew Walbran | 68a8c16 | 2022-03-07 15:38:42 +0000 | [diff] [blame] | 5 | rust_ffi_static { |
| 6 | name: "libpvmfw", |
| 7 | crate_name: "pvmfw", |
David Brazdil | 30a7f08 | 2022-07-07 15:30:14 +0100 | [diff] [blame] | 8 | defaults: ["vmbase_ffi_defaults"], |
Andrew Walbran | 68a8c16 | 2022-03-07 15:38:42 +0000 | [diff] [blame] | 9 | srcs: ["src/main.rs"], |
Pierre-Clément Tosi | e8726e4 | 2022-10-17 13:35:27 +0100 | [diff] [blame] | 10 | features: [ |
| 11 | "legacy", |
| 12 | ], |
Andrew Walbran | f259488 | 2022-03-15 17:32:53 +0000 | [diff] [blame] | 13 | rustlibs: [ |
Pierre-Clément Tosi | a8a4a20 | 2022-11-03 14:16:46 +0000 | [diff] [blame] | 14 | "libaarch64_paging", |
Alice Wang | 947f3f7 | 2023-09-29 09:04:07 +0000 | [diff] [blame] | 15 | "libbssl_avf_nostd", |
Pierre-Clément Tosi | 90cd4f1 | 2023-02-17 11:19:56 +0000 | [diff] [blame] | 16 | "libbssl_ffi_nostd", |
Alan Stokes | d1ee63e | 2023-04-24 16:17:39 +0100 | [diff] [blame] | 17 | "libciborium_nostd", |
| 18 | "libciborium_io_nostd", |
Alice Wang | cb9d2f9 | 2023-02-06 10:29:00 +0000 | [diff] [blame] | 19 | "libdiced_open_dice_nostd", |
Andrew Walbran | 730375d | 2022-12-21 14:04:34 +0000 | [diff] [blame] | 20 | "libfdtpci", |
Alice Wang | 0bdc3f6 | 2023-03-15 10:46:12 +0000 | [diff] [blame] | 21 | "libhyp", |
Pierre-Clément Tosi | a0934c1 | 2022-11-25 20:54:11 +0000 | [diff] [blame] | 22 | "liblibfdt", |
Pierre-Clément Tosi | 37105a6 | 2022-10-18 12:21:48 +0100 | [diff] [blame] | 23 | "liblog_rust_nostd", |
Andrew Walbran | b398fc8 | 2023-01-24 14:45:46 +0000 | [diff] [blame] | 24 | "libonce_cell_nostd", |
Pierre-Clément Tosi | 2d65298 | 2023-01-09 19:30:17 +0000 | [diff] [blame] | 25 | "libpvmfw_avb_nostd", |
Pierre-Clément Tosi | 4ef7522 | 2022-10-26 17:40:50 +0100 | [diff] [blame] | 26 | "libpvmfw_embedded_key", |
Jiyong Park | 216793e | 2023-02-25 02:15:44 +0900 | [diff] [blame] | 27 | "libpvmfw_fdt_template", |
Andrew Walbran | f44f160 | 2023-05-30 14:59:19 +0000 | [diff] [blame] | 28 | "libsmccc", |
Pierre-Clément Tosi | 1cc5eb7 | 2023-02-02 11:09:18 +0000 | [diff] [blame] | 29 | "libstatic_assertions", |
Pierre-Clément Tosi | 328dfb6 | 2022-11-25 18:20:42 +0000 | [diff] [blame] | 30 | "libtinyvec_nostd", |
Pierre-Clément Tosi | 1cc5eb7 | 2023-02-02 11:09:18 +0000 | [diff] [blame] | 31 | "libuuid_nostd", |
Andrew Walbran | d1d0318 | 2022-12-09 18:20:01 +0000 | [diff] [blame] | 32 | "libvirtio_drivers", |
Andrew Walbran | dd74b90 | 2022-04-14 16:12:50 +0000 | [diff] [blame] | 33 | "libvmbase", |
Alan Stokes | a0e4296 | 2023-04-14 17:59:50 +0100 | [diff] [blame] | 34 | "libzerocopy_nostd", |
Pierre-Clément Tosi | 8383c54 | 2022-11-01 14:07:29 +0000 | [diff] [blame] | 35 | "libzeroize_nostd", |
Jakob Vukalovic | 85a00d7 | 2023-04-20 09:51:10 +0100 | [diff] [blame] | 36 | "libspin_nostd", |
Andrew Walbran | f259488 | 2022-03-15 17:32:53 +0000 | [diff] [blame] | 37 | ], |
Andrew Walbran | 68a8c16 | 2022-03-07 15:38:42 +0000 | [diff] [blame] | 38 | } |
Andrew Walbran | 15068b0 | 2022-03-22 15:57:34 +0000 | [diff] [blame] | 39 | |
Alice Wang | 1c7e0eb | 2023-04-11 17:03:42 +0000 | [diff] [blame] | 40 | // Generates an empty file. |
| 41 | genrule { |
| 42 | name: "empty_file", |
| 43 | out: ["empty_file"], |
| 44 | cmd: "touch $(out)", |
| 45 | } |
| 46 | |
Jiyong Park | c5d2ef2 | 2023-04-11 01:23:46 +0900 | [diff] [blame] | 47 | rust_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"], |
Nikita Ioffe | da1b273 | 2023-09-04 13:46:56 +0100 | [diff] [blame] | 52 | defaults: ["avf_build_flags_rust"], |
Jiyong Park | c5d2ef2 | 2023-04-11 01:23:46 +0900 | [diff] [blame] | 53 | test_suites: ["general-tests"], |
| 54 | test_options: { |
| 55 | unit_test: true, |
| 56 | }, |
| 57 | rustlibs: [ |
| 58 | "libzeroize", |
| 59 | ], |
| 60 | } |
| 61 | |
Andrew Walbran | 15068b0 | 2022-03-22 15:57:34 +0000 | [diff] [blame] | 62 | cc_binary { |
Pierre-Clément Tosi | b130035 | 2022-09-09 11:01:06 +0100 | [diff] [blame] | 63 | name: "pvmfw", |
David Brazdil | 30a7f08 | 2022-07-07 15:30:14 +0100 | [diff] [blame] | 64 | defaults: ["vmbase_elf_defaults"], |
Andrew Walbran | 15068b0 | 2022-03-22 15:57:34 +0000 | [diff] [blame] | 65 | srcs: [ |
Andrew Walbran | 267f6c1 | 2022-03-24 11:26:36 +0000 | [diff] [blame] | 66 | "idmap.S", |
Andrew Walbran | 15068b0 | 2022-03-22 15:57:34 +0000 | [diff] [blame] | 67 | ], |
| 68 | static_libs: [ |
| 69 | "libpvmfw", |
| 70 | ], |
Andrew Walbran | a5b7af5 | 2022-07-06 15:06:20 +0000 | [diff] [blame] | 71 | linker_scripts: [ |
| 72 | "image.ld", |
| 73 | ":vmbase_sections", |
| 74 | ], |
Jiyong Park | 17b8d75 | 2022-12-16 14:36:24 +0900 | [diff] [blame] | 75 | // `installable: false` is inherited from vmbase_elf_defaults, and that |
| 76 | // hides this module from Make, which makes it impossible for the Make world |
| 77 | // to place the unstripped binary to the symbols directory. Marking back as |
| 78 | // installable exposes this module to the Make world again. Note that this |
| 79 | // module (pvmfw) still is NOT installed to any of the filesystem images. It |
| 80 | // is fed into pvmfw_bin and then into pvmfw_img to become a standalone |
| 81 | // partition image. This is just to package the unstripped file into the |
| 82 | // symbols zip file for debugging purpose. |
| 83 | installable: true, |
Andrew Walbran | 15068b0 | 2022-03-22 15:57:34 +0000 | [diff] [blame] | 84 | } |
David Brazdil | 05d4e07 | 2022-04-25 14:47:06 +0100 | [diff] [blame] | 85 | |
| 86 | raw_binary { |
Pierre-Clément Tosi | b130035 | 2022-09-09 11:01:06 +0100 | [diff] [blame] | 87 | name: "pvmfw_bin", |
| 88 | stem: "pvmfw.bin", |
| 89 | src: ":pvmfw", |
David Brazdil | 05d4e07 | 2022-04-25 14:47:06 +0100 | [diff] [blame] | 90 | enabled: false, |
| 91 | target: { |
| 92 | android_arm64: { |
| 93 | enabled: true, |
| 94 | }, |
| 95 | }, |
| 96 | } |
David Brazdil | ac216b5 | 2022-04-25 15:07:22 +0100 | [diff] [blame] | 97 | |
Jaewan Kim | 2cf6f39 | 2023-02-10 01:35:47 +0900 | [diff] [blame] | 98 | // 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. |
| 102 | prebuilt_etc { |
| 103 | name: "pvmfw_test", |
| 104 | filename: "pvmfw_test.bin", |
| 105 | target: { |
| 106 | android_arm64: { |
| 107 | src: ":pvmfw_bin", |
| 108 | }, |
| 109 | }, |
Alice Wang | 1c7e0eb | 2023-04-11 17:03:42 +0000 | [diff] [blame] | 110 | src: ":empty_file", |
Jaewan Kim | 2cf6f39 | 2023-02-10 01:35:47 +0900 | [diff] [blame] | 111 | installable: false, |
| 112 | } |
| 113 | |
Pierre-Clément Tosi | b5771c0 | 2022-09-06 16:01:35 +0100 | [diff] [blame] | 114 | prebuilt_etc { |
Pierre-Clément Tosi | 6ec2ae2 | 2022-10-26 15:14:45 +0100 | [diff] [blame] | 115 | name: "pvmfw_embedded_key", |
| 116 | src: ":avb_testkey_rsa4096_pub_bin", |
| 117 | installable: false, |
| 118 | } |
| 119 | |
Pierre-Clément Tosi | 4ef7522 | 2022-10-26 17:40:50 +0100 | [diff] [blame] | 120 | genrule { |
| 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 | |
| 133 | rust_library_rlib { |
| 134 | name: "libpvmfw_embedded_key", |
Pierre-Clément Tosi | 4894b43 | 2023-06-27 14:02:26 +0000 | [diff] [blame] | 135 | defaults: ["vmbase_rlib_defaults"], |
Pierre-Clément Tosi | 4ef7522 | 2022-10-26 17:40:50 +0100 | [diff] [blame] | 136 | srcs: [":pvmfw_embedded_key_rs"], |
| 137 | crate_name: "pvmfw_embedded_key", |
Pierre-Clément Tosi | 4ef7522 | 2022-10-26 17:40:50 +0100 | [diff] [blame] | 138 | } |
| 139 | |
Pierre-Clément Tosi | 6ec2ae2 | 2022-10-26 15:14:45 +0100 | [diff] [blame] | 140 | prebuilt_etc { |
Pierre-Clément Tosi | b5771c0 | 2022-09-06 16:01:35 +0100 | [diff] [blame] | 141 | name: "pvmfw_sign_key", |
| 142 | src: ":avb_testkey_rsa4096", |
| 143 | installable: false, |
| 144 | } |
| 145 | |
Jiyong Park | 9c1c818 | 2023-05-25 15:40:11 +0900 | [diff] [blame] | 146 | // We need to rename *.dts into *.cpp as cc_object doesn't accept *.dts as an |
| 147 | // input |
Jiyong Park | 216793e | 2023-02-25 02:15:44 +0900 | [diff] [blame] | 148 | genrule { |
Jiyong Park | 9c1c818 | 2023-05-25 15:40:11 +0900 | [diff] [blame] | 149 | name: "pvmfw_platform.dts.renamed", |
| 150 | srcs: ["platform.dts"], |
| 151 | out: ["out.cpp"], |
| 152 | cmd: "cp $(in) $(out)", |
| 153 | visibility: ["//visibility:private"], |
| 154 | } |
| 155 | |
| 156 | // Then run the macro processor to replace symbols like GIC_SPI into actual |
| 157 | // numbers defined in the ARM DT binding headers |
| 158 | cc_object { |
| 159 | name: "pvmfw_platform.dts.preprocessed", |
| 160 | header_libs: ["arm_dt_bindings_headers"], |
| 161 | host_supported: true, |
| 162 | srcs: [":pvmfw_platform.dts.renamed"], |
| 163 | cflags: [ |
| 164 | "-E", |
| 165 | "-P", |
| 166 | "-xassembler-with-cpp", // allow C preprocessor directives |
Jiyong Park | 216793e | 2023-02-25 02:15:44 +0900 | [diff] [blame] | 167 | ], |
Jiyong Park | 9c1c818 | 2023-05-25 15:40:11 +0900 | [diff] [blame] | 168 | visibility: ["//visibility:private"], |
| 169 | } |
| 170 | |
| 171 | // Compile the preprocessed dts into binary and create a rust library source |
| 172 | // having the binary. |
| 173 | cc_genrule { |
| 174 | name: "pvmfw_fdt_template_rs", |
| 175 | srcs: [":pvmfw_platform.dts.preprocessed"], |
Jiyong Park | 216793e | 2023-02-25 02:15:44 +0900 | [diff] [blame] | 176 | out: ["lib.rs"], |
| 177 | tools: ["dtc"], |
Jiyong Park | 9c1c818 | 2023-05-25 15:40:11 +0900 | [diff] [blame] | 178 | cmd: "$(location dtc) -I dts -O dtb -o $(genDir)/compiled.dtbo $(in) && " + |
Jiyong Park | 216793e | 2023-02-25 02:15:44 +0900 | [diff] [blame] | 179 | "(" + |
| 180 | " echo '#![no_std]';" + |
| 181 | " echo '#![allow(missing_docs)]';" + |
| 182 | " echo 'pub const RAW: &[u8] = &[';" + |
| 183 | " xxd -i < $(genDir)/compiled.dtbo;" + |
| 184 | " echo '];';" + |
| 185 | ") > $(out)", |
Jiyong Park | 9c1c818 | 2023-05-25 15:40:11 +0900 | [diff] [blame] | 186 | visibility: ["//visibility:private"], |
Jiyong Park | 216793e | 2023-02-25 02:15:44 +0900 | [diff] [blame] | 187 | } |
| 188 | |
| 189 | rust_library_rlib { |
| 190 | name: "libpvmfw_fdt_template", |
Pierre-Clément Tosi | 4894b43 | 2023-06-27 14:02:26 +0000 | [diff] [blame] | 191 | defaults: ["vmbase_rlib_defaults"], |
Jiyong Park | 216793e | 2023-02-25 02:15:44 +0900 | [diff] [blame] | 192 | srcs: [":pvmfw_fdt_template_rs"], |
| 193 | crate_name: "pvmfw_fdt_template", |
| 194 | } |
| 195 | |
David Brazdil | ac216b5 | 2022-04-25 15:07:22 +0100 | [diff] [blame] | 196 | bootimg { |
| 197 | name: "pvmfw_img", |
| 198 | stem: "pvmfw.img", |
| 199 | kernel_prebuilt: ":pvmfw_bin", |
| 200 | header_version: "3", |
| 201 | partition_name: "pvmfw", |
| 202 | enabled: false, |
| 203 | target: { |
| 204 | android_arm64: { |
| 205 | enabled: true, |
| 206 | }, |
| 207 | }, |
Pierre-Clément Tosi | b5771c0 | 2022-09-06 16:01:35 +0100 | [diff] [blame] | 208 | use_avb: true, |
| 209 | avb_private_key: ":pvmfw_sign_key", |
David Brazdil | ac216b5 | 2022-04-25 15:07:22 +0100 | [diff] [blame] | 210 | } |