sim: Add OldCorrect and NoUpgrade dependency types

Add two additional dependency types.  The NoUpgrade type indicates that
this slot should not contain an upgrade at all.  The OldCorrect
indicates a dependency on the old version of the other slot.

Signed-off-by: David Brown <david.brown@linaro.org>
Signed-off-by: Fabio Utzig <utzig@apache.org>
diff --git a/sim/src/depends.rs b/sim/src/depends.rs
index d1ea8a1..eecee08 100644
--- a/sim/src/depends.rs
+++ b/sim/src/depends.rs
@@ -54,9 +54,14 @@
     Nothing,
     /// Provide dependency information that matches the other image.
     Correct,
+    /// Provide a dependency that matches the old version of the other
+    /// image.
+    OldCorrect,
     /// Provide dependency information describing something newer than the
     /// other image.
     Newer,
+    /// Don't provide an upgrade image at all for this image
+    NoUpgrade,
 }
 
 /// Describes what our expectation is for an upgrade.
@@ -101,14 +106,24 @@
     }
 
     fn my_deps(&self, _offset: usize, slot: usize) -> Vec<ImageVersion> {
-        match self.test.depends[self.number] {
-            DepType::Nothing => vec![],
-            DepType::Correct => vec![
-                ImageVersion::new_synthetic(self.other_id(), slot as u8, 0)
-            ],
-            DepType::Newer => vec![
-                ImageVersion::new_synthetic(self.other_id(), slot as u8, 1)
-            ],
+        // For now, don't put any dependencies in slot zero.  They could be
+        // added here if we someday implement checking these.
+        if slot == 0 {
+            vec![]
+        } else {
+            match self.test.depends[self.number] {
+                DepType::Nothing => vec![],
+                DepType::NoUpgrade => panic!("Shouldn't get to this point"),
+                DepType::Correct => vec![
+                    ImageVersion::new_synthetic(self.other_id(), slot as u8, 0)
+                ],
+                DepType::OldCorrect => vec![
+                    ImageVersion::new_synthetic(self.other_id(), 0, 0)
+                ],
+                DepType::Newer => vec![
+                    ImageVersion::new_synthetic(self.other_id(), slot as u8, 1)
+                ],
+            }
         }
     }
 
diff --git a/sim/src/image.rs b/sim/src/image.rs
index 82cd729..88a85be 100644
--- a/sim/src/image.rs
+++ b/sim/src/image.rs
@@ -38,6 +38,7 @@
     BoringDep,
     Depender,
     DepTest,
+    DepType,
     PairDep,
     UpgradeInfo,
 };
@@ -167,7 +168,10 @@
                 Box::new(BoringDep(image_num))
             };
             let primaries = install_image(&mut flash, &slots[0], 42784, &*dep, false);
-            let upgrades = install_image(&mut flash, &slots[1], 46928, &*dep, false);
+            let upgrades = match deps.depends[image_num] {
+                DepType::NoUpgrade => install_no_image(),
+                _ => install_image(&mut flash, &slots[1], 46928, &*dep, false)
+            };
             OneImage {
                 slots: slots,
                 primaries: primaries,
@@ -1228,6 +1232,14 @@
     }
 }
 
+/// Install no image.  This is used when no upgrade happens.
+fn install_no_image() -> ImageData {
+    ImageData {
+        plain: vec![],
+        cipher: None,
+    }
+}
+
 fn make_tlv() -> TlvGen {
     if Caps::EcdsaP224.present() {
         panic!("Ecdsa P224 not supported in Simulator");