aboot: Check if booting into FFBM

FFBM is needed to start the system in native Android to shorten boot time
in case of factory testing. FFBM mode representation is string of the type
"ffbm-xx" where xx is number that denotes the FFBM submode.
LK reads that string from the misc partition during boot and passes it
transparently to kernel bootargs

Change-Id: Ib1a73463bb776b02478b626d174b93a9f592a0d8
diff --git a/app/aboot/aboot.c b/app/aboot/aboot.c
index 78bfd44..f242b93 100644
--- a/app/aboot/aboot.c
+++ b/app/aboot/aboot.c
@@ -89,6 +89,7 @@
 
 static const char *emmc_cmdline = " androidboot.emmc=true";
 static const char *usb_sn_cmdline = " androidboot.serialno=";
+static const char *androidboot_mode = " androidboot.mode=";
 static const char *battchg_pause = " androidboot.mode=charger";
 static const char *auth_kernel = " androidboot.authorized_kernel=true";
 
@@ -197,6 +198,8 @@
 	int have_cmdline = 0;
 	unsigned char *cmdline_final = NULL;
 	int pause_at_bootup = 0;
+	char ffbm[10];
+	bool boot_into_ffbm = get_ffbm(ffbm, sizeof(ffbm));
 
 	if (cmdline && cmdline[0]) {
 		cmdline_len = strlen(cmdline);
@@ -209,7 +212,10 @@
 	cmdline_len += strlen(usb_sn_cmdline);
 	cmdline_len += strlen(sn_buf);
 
-	if (target_pause_for_battery_charge()) {
+	if (boot_into_ffbm) {
+		cmdline_len += strlen(androidboot_mode);
+		cmdline_len += strlen(ffbm);
+	} else if (target_pause_for_battery_charge()) {
 		pause_at_bootup = 1;
 		cmdline_len += strlen(battchg_pause);
 	}
@@ -285,7 +291,14 @@
 		have_cmdline = 1;
 		while ((*dst++ = *src++));
 
-		if (pause_at_bootup) {
+		if (boot_into_ffbm) {
+			src = androidboot_mode;
+			if (have_cmdline) --dst;
+			while ((*dst++ = *src++));
+			src = ffbm;
+			if (have_cmdline) --dst;
+			while ((*dst++ = *src++));
+		} else if (pause_at_bootup) {
 			src = battchg_pause;
 			if (have_cmdline) --dst;
 			while ((*dst++ = *src++));