cgpt: Update behavior of GptUpdateKernelWithEntry
In order to support slots, we need to update behavior of
GptUpdateKernelWithEntry so that:
1. Invalid - Marks kernel entry as invalid
2. Active - Marks kernel entry as active
CQ-DEPEND=CL:336906
BUG=chrome-os-partner:51807
BRANCH=None
TEST=Compiles successfully "sudo emerge vboot_reference" "emerge-smaug
vboot_reference". "make -j runtests" successful.
Change-Id: If248b3c6bdd23d03cb1dd24f4e21cacef5cc3f26
Signed-off-by: Furquan Shaikh <furquan@google.com>
Reviewed-on: https://chromium-review.googlesource.com/335942
Commit-Ready: Furquan Shaikh <furquan@chromium.org>
Tested-by: Furquan Shaikh <furquan@chromium.org>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
diff --git a/firmware/include/gpt_misc.h b/firmware/include/gpt_misc.h
index 49e1351..9f442c4 100644
--- a/firmware/include/gpt_misc.h
+++ b/firmware/include/gpt_misc.h
@@ -51,12 +51,12 @@
*/
GPT_UPDATE_ENTRY_BAD = 2,
/*
- * Used for fastboot mode. When an image is written to kernel partition,
- * its GPT entry is marked with S1,P1,T15.
+ * Used for fastboot mode. If kernel partition slot is marked active,
+ * its GPT entry is marked with S1,P2,T0.
*/
- GPT_UPDATE_ENTRY_RESET = 3,
+ GPT_UPDATE_ENTRY_ACTIVE = 3,
/*
- * Used for fastboot mode. When an image is written to kernel partition,
+ * Used for fastboot mode. If kernel partition slot is marked invalid,
* its GPT entry is marked with S0,P0,T0.
*/
GPT_UPDATE_ENTRY_INVALID = 4,
diff --git a/firmware/lib/cgptlib/cgptlib.c b/firmware/lib/cgptlib/cgptlib.c
index 05ee29c..11512a0 100644
--- a/firmware/lib/cgptlib/cgptlib.c
+++ b/firmware/lib/cgptlib/cgptlib.c
@@ -157,21 +157,21 @@
}
break;
}
- case GPT_UPDATE_ENTRY_RESET: {
+ case GPT_UPDATE_ENTRY_ACTIVE: {
/*
- * Used for fastboot mode. If image is written to kernel
- * partition, its GPT entry is marked with S1,P1,T15
+ * Used for fastboot mode. If kernel partition slot is marked
+ * active, its GPT entry is marked with S1,P2,T0.
*/
modified = 1;
- SetEntryTries(e, 15);
- SetEntryPriority(e, 1);
+ SetEntryTries(e, 0);
+ SetEntryPriority(e, 2);
SetEntrySuccessful(e, 1);
break;
}
case GPT_UPDATE_ENTRY_INVALID: {
/*
- * Used for fastboot mode. If kernel partition is erased, its
- * GPT entry is marked with S0,P0,T0
+ * Used for fastboot mode. If kernel partition slot is marked
+ * invalid, its GPT entry is marked with S0,P0,T0
*/
modified = 1;
SetEntryTries(e, 0);