From cd0be6a7bf2f1c5a81023db38f4edea3c2f40ce8 Mon Sep 17 00:00:00 2001
From: David Cotton <dcotton@gitlab.riscosopen.org>
Date: Tue, 10 Apr 2001 07:46:24 +0000
Subject: [PATCH] New OS_NVMemory reason code added.

Detail:
    OS_NVMemory 5 - read / write value of NVRamWriteSize
    in:  R0 = 5
         R1 = new value of NVRamWriteSize (in bytes, multiple of 256), or -1
              to return size.
    out: R1 = value of NVRamWriteSize
    This can be used to read and set the size of the protected area of NVRAM.
This is needed for Customer A 2, where there is a need to deprotect the protected
area so that NVRAM tags can be written.

Admin:
    Code by MStephens. Built and checked in by me ;-)

Version 5.41. Tagged as 'Kernel-5_41'
---
 VersionASM     | 14 +++++++-------
 VersionNum     | 20 ++++++++++----------
 s/PMF/i2cutils | 24 ++++++++++++++++++++++++
 3 files changed, 41 insertions(+), 17 deletions(-)

diff --git a/VersionASM b/VersionASM
index c831e9ac..8caf816f 100644
--- a/VersionASM
+++ b/VersionASM
@@ -11,14 +11,14 @@
                         GBLS    Module_HelpVersion
                         GBLS    Module_ComponentName
                         GBLS    Module_ComponentPath
-Module_MajorVersion     SETS    "5.40"
-Module_Version          SETA    540
+Module_MajorVersion     SETS    "5.41"
+Module_Version          SETA    541
 Module_MinorVersion     SETS    ""
-Module_Date             SETS    "02 Apr 2001"
-Module_ApplicationDate2 SETS    "02-Apr-01"
-Module_ApplicationDate4 SETS    "02-Apr-2001"
+Module_Date             SETS    "10 Apr 2001"
+Module_ApplicationDate2 SETS    "10-Apr-01"
+Module_ApplicationDate4 SETS    "10-Apr-2001"
 Module_ComponentName    SETS    "Kernel"
 Module_ComponentPath    SETS    "RiscOS/Sources/Kernel"
-Module_FullVersion      SETS    "5.40"
-Module_HelpVersion      SETS    "5.40 (02 Apr 2001)"
+Module_FullVersion      SETS    "5.41"
+Module_HelpVersion      SETS    "5.41 (10 Apr 2001)"
                         END
diff --git a/VersionNum b/VersionNum
index cec95d2a..bfd0d6dd 100644
--- a/VersionNum
+++ b/VersionNum
@@ -1,22 +1,22 @@
-/* (5.40)
+/* (5.41)
  *
  * This file is automatically maintained by srccommit, do not edit manually.
  *
  */
-#define Module_MajorVersion_CMHG        5.40
+#define Module_MajorVersion_CMHG        5.41
 #define Module_MinorVersion_CMHG        
-#define Module_Date_CMHG                02 Apr 2001
+#define Module_Date_CMHG                10 Apr 2001
 
-#define Module_MajorVersion             "5.40"
-#define Module_Version                  540
+#define Module_MajorVersion             "5.41"
+#define Module_Version                  541
 #define Module_MinorVersion             ""
-#define Module_Date                     "02 Apr 2001"
+#define Module_Date                     "10 Apr 2001"
 
-#define Module_ApplicationDate2         "02-Apr-01"
-#define Module_ApplicationDate4         "02-Apr-2001"
+#define Module_ApplicationDate2         "10-Apr-01"
+#define Module_ApplicationDate4         "10-Apr-2001"
 
 #define Module_ComponentName            "Kernel"
 #define Module_ComponentPath            "RiscOS/Sources/Kernel"
 
-#define Module_FullVersion              "5.40"
-#define Module_HelpVersion              "5.40 (02 Apr 2001)"
+#define Module_FullVersion              "5.41"
+#define Module_HelpVersion              "5.41 (10 Apr 2001)"
diff --git a/s/PMF/i2cutils b/s/PMF/i2cutils
index f87ab27e..0e429d5a 100644
--- a/s/PMF/i2cutils
+++ b/s/PMF/i2cutils
@@ -1901,6 +1901,9 @@ NVMemorySub
         B       NVMemory_Write
         B       NVMemory_ReadBlock
         B       NVMemory_WriteBlock
+  [ E2ROMSupport
+        B       NVMemory_WriteSize
+  ]
 
 NVMemory_Unknown
         ADRL    R0, ErrorBlock_HeapBadReason
@@ -2025,4 +2028,25 @@ NVMemory_WriteBlock ROUT
         msr    ,CPSR_cf, R4     ; restore interrupt state
         EXIT
 
+; -----------------------------------------------------------------------------
+; OS_NVMemory 5 - read/write value of NVRamWriteSize
+;
+; in:   R0 = 5
+;       R1 = new value of NVRamWriteSize (in bytes, multiple of 256), or -1 to read
+; out:  R1 = value of NVRamWriteSize (in bytes)
+;
+  [ E2ROMSupport
+
+NVMemory_WriteSize ROUT
+        ENTRY   "R2"
+        MOV     R2, #0
+        CMP     R1, #-1
+        LDREQB  R1, [R2, #NVRamWriteSize]
+        MOVNE   R1, R1, LSR #8
+        STRNEB  R1, [R2, #NVRamWriteSize]
+        MOV     R1, R1, LSL #8             ; convert to bytes
+        EXIT
+
+  ] ; E2ROMSupport
+
 	END
-- 
GitLab