From b213fdd5df9da0a4d86c815defe0147c4f60403f Mon Sep 17 00:00:00 2001
From: Jeffrey Lee <jlee@gitlab.riscosopen.org>
Date: Sun, 28 Feb 2010 19:33:57 +0000
Subject: [PATCH] Update VDU HAL device for new OMAPVideo driver, fix MVA-based
 cache/TLB maintenance ops aborting on ARMv7, add warning to VDU driver about
 inconsistent state variables during screen mode changes

Detail:
  hdr/VideoDevice - removed Address2 and Device2 fields as it makes more sense for them to be in the device specific field (which for OMAP3 is a pointer to an OMAP3-specific struct)
  s/VMSAv6 - Modify data abort handler to ignore aborts that are generated by MVA-based cache/TLB maintenance ops. Unlike earlier ARM architectures, MVA-based ops can abort under ARMv7 if the page has no mapping to a physical address.
  s/vdu/vdudriver - Add a warning about VDU driver state variables (particularly CursorAddr) being left in invalid states during the execution of mode changes. This can cause problems if any attempt is made to output to the screen during the mode change (e.g. as a result of an abort)
Admin:
  Tested on rev C2 beagleboard. Video device changes mean that OMAP3 HAL 0.23 will be needed for ROM compilation to succeed.


Version 5.35, 4.79.2.98.2.24. Tagged as 'Kernel-5_35-4_79_2_98_2_24'
---
 VersionASM      | 10 +++++-----
 VersionNum      | 14 +++++++-------
 hdr/VideoDevice | 10 ++++------
 s/VMSAv6        | 25 ++++++++++++++++++++-----
 s/vdu/vdudriver |  2 ++
 5 files changed, 38 insertions(+), 23 deletions(-)

diff --git a/VersionASM b/VersionASM
index cc5bcc4..c9f2267 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.98.2.23"
-Module_Date             SETS    "20 Feb 2010"
-Module_ApplicationDate  SETS    "20-Feb-10"
+Module_MinorVersion     SETS    "4.79.2.98.2.24"
+Module_Date             SETS    "28 Feb 2010"
+Module_ApplicationDate  SETS    "28-Feb-10"
 Module_ComponentName    SETS    "Kernel"
 Module_ComponentPath    SETS    "castle/RiscOS/Sources/Kernel"
-Module_FullVersion      SETS    "5.35 (4.79.2.98.2.23)"
-Module_HelpVersion      SETS    "5.35 (20 Feb 2010) 4.79.2.98.2.23"
+Module_FullVersion      SETS    "5.35 (4.79.2.98.2.24)"
+Module_HelpVersion      SETS    "5.35 (28 Feb 2010) 4.79.2.98.2.24"
                         END
diff --git a/VersionNum b/VersionNum
index 7925c65..8bce507 100644
--- a/VersionNum
+++ b/VersionNum
@@ -5,19 +5,19 @@
  *
  */
 #define Module_MajorVersion_CMHG        5.35
-#define Module_MinorVersion_CMHG        4.79.2.98.2.23
-#define Module_Date_CMHG                20 Feb 2010
+#define Module_MinorVersion_CMHG        4.79.2.98.2.24
+#define Module_Date_CMHG                28 Feb 2010
 
 #define Module_MajorVersion             "5.35"
 #define Module_Version                  535
-#define Module_MinorVersion             "4.79.2.98.2.23"
-#define Module_Date                     "20 Feb 2010"
+#define Module_MinorVersion             "4.79.2.98.2.24"
+#define Module_Date                     "28 Feb 2010"
 
-#define Module_ApplicationDate          "20-Feb-10"
+#define Module_ApplicationDate          "28-Feb-10"
 
 #define Module_ComponentName            "Kernel"
 #define Module_ComponentPath            "castle/RiscOS/Sources/Kernel"
 
-#define Module_FullVersion              "5.35 (4.79.2.98.2.23)"
-#define Module_HelpVersion              "5.35 (20 Feb 2010) 4.79.2.98.2.23"
+#define Module_FullVersion              "5.35 (4.79.2.98.2.24)"
+#define Module_HelpVersion              "5.35 (28 Feb 2010) 4.79.2.98.2.24"
 #define Module_LibraryVersionInfo       "5:35"
diff --git a/hdr/VideoDevice b/hdr/VideoDevice
index e0b0197..f055bce 100644
--- a/hdr/VideoDevice
+++ b/hdr/VideoDevice
@@ -26,12 +26,10 @@ Included_Hdr_VideoDevice SETL {TRUE}
 
 ; Device for VDU video devices
 
-                                ^       0
-                                #       HALDeviceSize
-HALDevice_VDUAddress2           #       4
-HALDevice_VDUDevice2            #       4
-HALDevice_VDUDeviceSpecificField #      4
-HALDevice_VDU_Size              *       :INDEX: @
+                                 ^       0
+                                 #       HALDeviceSize
+HALDevice_VDUDeviceSpecificField #       4
+HALDevice_VDU_Size               *       :INDEX: @
 
  ]
 
diff --git a/s/VMSAv6 b/s/VMSAv6
index dfffc45..42d17f3 100644
--- a/s/VMSAv6
+++ b/s/VMSAv6
@@ -552,15 +552,30 @@ DAbPreVeneer    ROUT
 
         SUB     r11, r2, #8*4                   ; r11 -> register bank
         STR     r4, [sp, #7*4]                  ; store aborter's PC in user register bank
-
-      [ {TRUE}
-        ; For now, don't attempt any fixup on ARMv6+, since we'll get it wrong
-        B       %FT90
-      ]
+; B %FT90
 
         TST     r0, #T32_bit                    ; were they in Thumb mode? if so, give up now
         BNE     %FT90
 
+ [ {TRUE}
+        ; For now, the only fixup we do is for MVA-based cache/TLB ops, which can abort on ARMv7 if the specified MVA doesn't have a mapping.
+        ; MVA cache ops have the form coproc=p15, CRn=c7, opc1=0, opc2=1
+        ; MVA TLB ops have the form coproc=p15, CRn=c8, opc=0, opc2=1
+        ; Note that some non-MVA ops also follow the above rules - at the moment we make no attempt to filter those false-positives out
+        ; This code is also written from the perspective of running on an ARMv7 CPU - behaviour under ARMv6 hasn't been checked!
+        LDR     r10, [r4, #-8]                  ; Get aborting instruction
+        CMP     r10, #&F0000000
+        BHS     %FT90                           ; Ignore cc=NV, which is MCR2 encoding
+        LDR     r9, =&0FFF0FF0                  ; Mask of interesting bits
+        AND     r10,r10,r9
+        LDR     r9, =&0E000F30                  ; Desired value, minus CRn
+        EOR     r10,r10,r9
+        CMP     r10, #&70000                    ; CRn=c7?
+        CMPNE   r10, #&80000                    ; CRn=c8?
+        BEQ     %FT70                           ; It's an MVA-based op. Ignore the abort and resume execution
+        B       %FT90                           ; Else skip the old & broken LDR/STR fixup code and go straight to the exception handler,
+ ]
+
 ;ARM 810 or StrongARM allow signed byte load or half-word load/stores - not supported at present
 ;***KJB - need to think about LDRH family
         LDR     r10, [r4, #-8]!                 ; r10 = actual instruction that aborted, and r4 points to it
diff --git a/s/vdu/vdudriver b/s/vdu/vdudriver
index ed82277..20bebb6 100644
--- a/s/vdu/vdudriver
+++ b/s/vdu/vdudriver
@@ -803,6 +803,8 @@ mchsub_3
 
 ; try to extend the amount of screen memory
 
+        ! 0, "Need to fix ModeChangeSub to not leave CursorAddr, etc. pointing to unmapped pages during DA resize. Causes bad stuff should an abort occur/screen output be attempted!" ; Note that even enlarging the DA can leave the pointers in a bad state, due to the way the screen DA handler shuffles down/unmaps the lower mapping of VRAM before the higher copy is enlarged
+
         MOV     R0, #2                  ; expand screen memory
         SWI     XOS_ChangeDynamicArea
         BVC     %FT08
-- 
GitLab