Microdroid runs on cuttlefish_x86_64

This CL includes x86_64 specific changes that are required to run
microdroid on cuttlefish_x86_64.

1) Unsigned bootloader is used. (b/185115783)
2) androidboot.boot_devices is correctly set for the architecture
3) uboot-env.txt is customized to set loadaddr
4) MicrodroidTestCase is revised to handle the case when multiple
devices are connected.

Bug: 185115783
Bug: 185082754
Test: atest MicrodroidHostTests with aosp_cf_x86_64_phone

Change-Id: I1baebedd392f742f9a9cd064d63a8c3741e46daa
diff --git a/microdroid/Android.bp b/microdroid/Android.bp
index 8456591..08870ba 100644
--- a/microdroid/Android.bp
+++ b/microdroid/Android.bp
@@ -132,6 +132,14 @@
     ],
 }
 
+// TODO(jiyong): change the name to init, cause it's confusing
+microdroid_boot_cmdline = "rdinit=/bin/init_vendor " +
+    "panic=-1 " +
+    // TODO(b/181936135) make the ratelimiting conditional; ratelimiting on prod build
+    "printk.devkmsg=on " +
+    "androidboot.first_stage_console=1 " +
+    "androidboot.hardware=microdroid "
+
 bootimg {
     name: "microdroid_boot-5.10",
     ramdisk_module: "microdroid_ramdisk-5.10",
@@ -141,19 +149,16 @@
     arch: {
         arm64: {
             kernel_prebuilt: ":kernel_prebuilts-5.10-arm64",
+            cmdline: microdroid_boot_cmdline +
+                "androidboot.boot_devices=10000.pci",
         },
         x86_64: {
             kernel_prebuilt: ":kernel_prebuilts-5.10-x86_64",
+            cmdline: microdroid_boot_cmdline +
+                "pci=noacpi " +
+                "androidboot.boot_devices=pci0000:00/0000:00:01.0",
         },
     },
-    // TODO(jiyong): change the name to init, cause it's confusing
-    cmdline: "rdinit=/bin/init_vendor " +
-        "panic=-1 " +
-        // TODO(b/181936135) make the ratelimiting conditional; ratelimiting on prod build
-        "printk.devkmsg=on " +
-        "androidboot.first_stage_console=1 " +
-        "androidboot.hardware=microdroid " +
-        "androidboot.boot_devices=10000.pci ",
     dtb_prebuilt: "dummy_dtb.img",
     header_version: "4",
     partition_name: "boot",
@@ -227,6 +232,14 @@
 prebuilt_etc {
     name: "microdroid_bootloader",
     src: ":microdroid_bootloader_gen",
+    arch: {
+        x86_64: {
+            // For unknown reason, the signed bootloader doesn't work on x86_64. Until the problem
+            // is fixed, let's use the unsigned bootloader for the architecture.
+            // TODO(b/185115783): remove this
+            src: ":cuttlefish_crosvm_bootloader",
+        },
+    },
     filename: "microdroid_bootloader",
 }
 
@@ -262,6 +275,11 @@
 prebuilt_etc {
     name: "microdroid_uboot_env",
     src: ":microdroid_uboot_env_gen",
+    arch: {
+        x86_64: {
+            src: ":microdroid_uboot_env_gen_x86_64",
+        },
+    },
     filename: "uboot_env.img",
 }
 
@@ -273,6 +291,14 @@
     cmd: "$(location mkenvimage_host) -s 4096 -o $(out) $(in)",
 }
 
+genrule {
+    name: "microdroid_uboot_env_gen_x86_64",
+    tools: ["mkenvimage_host"],
+    srcs: ["uboot-env-x86_64.txt"],
+    out: ["output.img"],
+    cmd: "$(location mkenvimage_host) -s 4096 -o $(out) $(in)",
+}
+
 // sepolicy sha256 for vendor
 prebuilt_etc {
     name: "microdroid_precompiled_sepolicy.plat_sepolicy_and_mapping.sha256",