From 1de5def170a96d8a5d6a50a1759128e4554e2bc2 Mon Sep 17 00:00:00 2001 From: Lepton Wu Date: Fri, 15 May 2020 17:11:13 -0700 Subject: Put files in device tree for Android With this, Android can access files from host in early stage so it can import properties from host. To avoid introduce more command line flags, just reuse the fstab file: any entries begin with #dt-vendor means a host side file need to be put in device tree. BUG=b:155128030 TEST=manual - Run ARCVM and check there is file under sysfs Change-Id: I6b209e05faabd3a82fe0194cf462ee450918ae5c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2203298 Reviewed-by: Chirantan Ekbote Tested-by: Lepton Wu Auto-Submit: Lepton Wu --- arch/src/android.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/arch/src/android.rs b/arch/src/android.rs index 3d459d4..5311d3f 100644 --- a/arch/src/android.rs +++ b/arch/src/android.rs @@ -31,9 +31,17 @@ pub fn create_android_fdt(fdt: &mut Vec, fstab: File) -> Result<()> { begin_node(fdt, "firmware")?; begin_node(fdt, "android")?; property_string(fdt, "compatible", "android,firmware")?; + + let (dtprop, fstab): (_, Vec<_>) = vecs.into_iter().partition(|x| x[0] == "#dt-vendor"); + begin_node(fdt, "vendor")?; + for vec in dtprop { + let content = std::fs::read_to_string(&vec[2]).map_err(Error::FdtIoError)?; + property_string(fdt, &vec[1], &content); + } + end_node(fdt)?; // vendor begin_node(fdt, "fstab")?; property_string(fdt, "compatible", "android,fstab")?; - for vec in vecs { + for vec in fstab { let partition = &vec[1][1..]; begin_node(fdt, partition)?; property_string(fdt, "compatible", &("android,".to_owned() + partition))?; -- cgit 1.4.1