app: aboot: Add Rollback index functions for AVB.

Add read and write rollback index functions to
read and update the rollback index of partitions.

Change-Id: I52b3fef94880f69798475162e29a3bb0e96f4888
diff --git a/app/aboot/aboot.c b/app/aboot/aboot.c
index 85f5b29..5024edc 100644
--- a/app/aboot/aboot.c
+++ b/app/aboot/aboot.c
@@ -2335,6 +2335,39 @@
 	}
 }
 
+int read_rollback_index(uint32_t loc, uint64_t *roll_back_index)
+{
+        if (!devinfo_present) {
+                dprintf(CRITICAL, "DeviceInfo not initalized \n");
+                return -EINVAL;
+        }
+        if (loc >= ARRAY_SIZE(device.rollback_index)) {
+                dprintf(CRITICAL, "%s() Loc out of range index: %d, array len: %d\n",
+                                __func__, loc, ARRAY_SIZE(device.rollback_index));
+                ASSERT(0);
+        }
+
+        *roll_back_index = device.rollback_index[loc];
+        return 0;
+}
+
+int write_rollback_index(uint32_t loc, uint64_t roll_back_index)
+{
+        if (!devinfo_present) {
+                dprintf(CRITICAL, "DeviceInfo not initalized \n");
+                return -EINVAL;
+        }
+        if (loc >= ARRAY_SIZE(device.rollback_index)) {
+                dprintf(CRITICAL, "%s() Loc out of range index: %d, array len: %d\n",
+                                __func__, loc, ARRAY_SIZE(device.rollback_index));
+                ASSERT(0);
+        }
+
+        device.rollback_index[loc] = roll_back_index;
+        write_device_info(&device);
+        return 0;
+}
+
 void read_device_info(device_info *dev)
 {
 	if(target_is_emmc_boot())
diff --git a/include/platform.h b/include/platform.h
index f7a14cb..f6f739f 100644
--- a/include/platform.h
+++ b/include/platform.h
@@ -95,4 +95,6 @@
 int LoadImage(char *Pname, void **ImgBuf, uint32_t *ImgSzActual);
 void boot_verifier_init();
 uint32_t get_page_size();
+int read_rollback_index(uint32_t loc, uint64_t *roll_back_index);
+int write_rollback_index(uint32_t loc, uint64_t roll_back_index);
 #endif