PMU counter shadow

Storing PMU counters in shadow variables, in case the PMU was powered
off or soft reset.

Change-Id: I64ccf3fb6195f9be2d8315891ec612bb75404885
diff --git a/include/ethosu_device.h b/include/ethosu_device.h
index 5edba94..91aa877 100644
--- a/include/ethosu_device.h
+++ b/include/ethosu_device.h
@@ -54,15 +54,15 @@
 
 struct ethosu_device
 {
-    uintptr_t base_address;
+    volatile uint32_t *base_address;
     uint32_t reset;
     uint32_t pmcr;
-    uint64_t pmccntr;
+    uint32_t pmccntr[2];
     uint32_t pmcnten;
     uint32_t pmint;
     uint32_t pmccntr_cfg;
     uint32_t pmu_evcntr[ETHOSU_PMU_NCOUNTERS];
-    enum ethosu_pmu_event_type pmu_evtypr[ETHOSU_PMU_NCOUNTERS];
+    uint32_t pmu_evtypr[ETHOSU_PMU_NCOUNTERS];
 };
 
 struct ethosu_id
@@ -378,6 +378,13 @@
 void ethosu_write_reg(struct ethosu_device *dev, uint32_t address, uint32_t value);
 
 /**
+ * Write register with shadow variable.
+ * \param[in] address          Address to read.
+ * \param[in] value            Value to be written.
+ */
+void ethosu_write_reg_shadow(struct ethosu_device *dev, uint32_t address, uint32_t value, uint32_t *shadow);
+
+/**
  * Save the PMU configuration to ethosu_device struct.
  * \param[in] dev              Ethos-U device where the PMU configuration is
  *                             saved.
@@ -394,6 +401,14 @@
 enum ethosu_error_codes ethosu_restore_pmu_config(struct ethosu_device *dev);
 
 /**
+ * Save PMU counters to shadow variables in memory.
+ * \param[in] dev              Ethos-U device where the PMU configuration is
+ *                             stored.
+ * \return                     \ref ethosu_error_codes
+ */
+enum ethosu_error_codes ethosu_save_pmu_counters(struct ethosu_device *dev);
+
+/**
  * Check if the STATUS register has any error bits set or not.
  * \param[in] dev              Ethos-U device to check.
  * \return                     true if any error bits set,