From 0283207543e5bfb5784bf709fb8f47eab639e318 Mon Sep 17 00:00:00 2001
From: Robert Sprowson <rsprowson@gitlab.riscosopen.org>
Date: Wed, 1 Oct 2014 07:45:04 +0000
Subject: [PATCH] Fix for spurious IIC access when probing

When HAL_NVMemoryType reports NVMemoryFlag_MaybeIIC the kernel tries to probe a number of common/known addresses on startup, however the result of the probe is stored around line 1346 without a value value for zero page in R2.
This is sufficiently early on that the default data abort handler (from when probing the ARM's abort model) is still in place so the stores are silently skipped.
Due to the RAM clear the NVRamBase (and size) are 0, which later on in ValChecksum result in a zero length IIC probe to address &01.
Now, R2 is initialised.

Version 5.35, 4.79.2.239. Tagged as 'Kernel-5_35-4_79_2_239'
---
 VersionASM     | 10 +++++-----
 VersionNum     | 14 +++++++-------
 s/PMF/i2cutils |  2 ++
 3 files changed, 14 insertions(+), 12 deletions(-)

diff --git a/VersionASM b/VersionASM
index 6d27cd1..5f8130e 100644
--- a/VersionASM
+++ b/VersionASM
@@ -13,11 +13,11 @@
                         GBLS    Module_ComponentPath
 Module_MajorVersion     SETS    "5.35"
 Module_Version          SETA    535
-Module_MinorVersion     SETS    "4.79.2.238"
-Module_Date             SETS    "18 Sep 2014"
-Module_ApplicationDate  SETS    "18-Sep-14"
+Module_MinorVersion     SETS    "4.79.2.239"
+Module_Date             SETS    "01 Oct 2014"
+Module_ApplicationDate  SETS    "01-Oct-14"
 Module_ComponentName    SETS    "Kernel"
 Module_ComponentPath    SETS    "castle/RiscOS/Sources/Kernel"
-Module_FullVersion      SETS    "5.35 (4.79.2.238)"
-Module_HelpVersion      SETS    "5.35 (18 Sep 2014) 4.79.2.238"
+Module_FullVersion      SETS    "5.35 (4.79.2.239)"
+Module_HelpVersion      SETS    "5.35 (01 Oct 2014) 4.79.2.239"
                         END
diff --git a/VersionNum b/VersionNum
index f28b4c8..e2d704f 100644
--- a/VersionNum
+++ b/VersionNum
@@ -5,19 +5,19 @@
  *
  */
 #define Module_MajorVersion_CMHG        5.35
-#define Module_MinorVersion_CMHG        4.79.2.238
-#define Module_Date_CMHG                18 Sep 2014
+#define Module_MinorVersion_CMHG        4.79.2.239
+#define Module_Date_CMHG                01 Oct 2014
 
 #define Module_MajorVersion             "5.35"
 #define Module_Version                  535
-#define Module_MinorVersion             "4.79.2.238"
-#define Module_Date                     "18 Sep 2014"
+#define Module_MinorVersion             "4.79.2.239"
+#define Module_Date                     "01 Oct 2014"
 
-#define Module_ApplicationDate          "18-Sep-14"
+#define Module_ApplicationDate          "01-Oct-14"
 
 #define Module_ComponentName            "Kernel"
 #define Module_ComponentPath            "castle/RiscOS/Sources/Kernel"
 
-#define Module_FullVersion              "5.35 (4.79.2.238)"
-#define Module_HelpVersion              "5.35 (18 Sep 2014) 4.79.2.238"
+#define Module_FullVersion              "5.35 (4.79.2.239)"
+#define Module_HelpVersion              "5.35 (01 Oct 2014) 4.79.2.239"
 #define Module_LibraryVersionInfo       "5:35"
diff --git a/s/PMF/i2cutils b/s/PMF/i2cutils
index 75a2796..71d4a51 100644
--- a/s/PMF/i2cutils
+++ b/s/PMF/i2cutils
@@ -1198,6 +1198,7 @@ InitCMOSCache   Entry "r1-r6, sb,r12"
         CallHAL HAL_NVMemoryType
         MOV     R5, R0
         ANDS    R0, R0, #NVMemoryFlag_Provision
+        ASSERT  NVMemoryFlag_None = 0
         BEQ     InitCMOSCache_NoCMOS
 
         ; If it's only a maybe, then we probe
@@ -1340,6 +1341,7 @@ InitCMOSCache_NoCMOS
 
 5
         ; Set the NVRam count
+        LDR     R2, =ZeroPage
         STRB    R1, [R2, #NVRamBase]
         STRB    R4, [R2, #NVRamSize]
         STRB    R5, [R2, #NVRamPageSize]
-- 
GitLab