Add derive_microdroid_vendor_dice_node binary
This patch introduces a skeleton of the binary that will be executed in
the first_stage_init to derive a new dice chain with node that
corresponds to the microdroid vendor partition.
Actual implementation will be done in the follow-up patch.
Bug: 287593065
Test: check that binary is executed
Change-Id: Iba68bb52de27fcdf426410d36aca6a29bcc59d7c
diff --git a/microdroid/Android.bp b/microdroid/Android.bp
index eebe153..e19a343 100644
--- a/microdroid/Android.bp
+++ b/microdroid/Android.bp
@@ -157,6 +157,9 @@
// Below are dependencies that are conditionally enabled depending on value of build flags.
soong_config_variables: {
release_avf_enable_dice_changes: {
+ deps: [
+ "derive_microdroid_vendor_dice_node",
+ ],
dirs: [
"microdroid_resources",
],
diff --git a/microdroid/derive_microdroid_vendor_dice_node/Android.bp b/microdroid/derive_microdroid_vendor_dice_node/Android.bp
new file mode 100644
index 0000000..de1bef7
--- /dev/null
+++ b/microdroid/derive_microdroid_vendor_dice_node/Android.bp
@@ -0,0 +1,22 @@
+package {
+ default_applicable_licenses: ["Android-Apache-2.0"],
+}
+
+rust_defaults {
+ name: "derive_microdroid_vendor_dice_node_defaults",
+ crate_name: "derive_microdroid_vendor_dice_node",
+ defaults: ["avf_build_flags_rust"],
+ srcs: ["src/main.rs"],
+ rustlibs: [
+ "libanyhow",
+ "libclap",
+ ],
+ bootstrap: true,
+ prefer_rlib: true,
+}
+
+rust_binary {
+ name: "derive_microdroid_vendor_dice_node",
+ defaults: ["derive_microdroid_vendor_dice_node_defaults"],
+ stem: "derive_microdroid_vendor_dice_node",
+}
diff --git a/microdroid/derive_microdroid_vendor_dice_node/src/main.rs b/microdroid/derive_microdroid_vendor_dice_node/src/main.rs
new file mode 100644
index 0000000..1d5db0d
--- /dev/null
+++ b/microdroid/derive_microdroid_vendor_dice_node/src/main.rs
@@ -0,0 +1,38 @@
+// Copyright 2024, The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+//! Derives microdroid vendor dice node.
+
+use anyhow::Error;
+use clap::Parser;
+use std::path::PathBuf;
+
+#[derive(Parser)]
+struct Args {
+ /// Path to the dice driver (e.g. /dev/open-dice0)
+ #[arg(long)]
+ dice_driver: PathBuf,
+ /// Path to the microdroid-vendor.img disk image.
+ #[arg(long)]
+ microdroid_vendor_disk_image: PathBuf,
+ /// File to save resulting dice chain to.
+ #[arg(long)]
+ output: PathBuf,
+}
+
+fn main() -> Result<(), Error> {
+ let args = Args::parse();
+ eprintln!("{:?} {:?} {:?}", args.dice_driver, args.microdroid_vendor_disk_image, args.output);
+ Ok(())
+}