Commit 82a9c908 authored by Jeffrey Lee's avatar Jeffrey Lee Committed by ROOL

Ensure IIC bus list is fully initialised

IICInit only initialises the entries for valid IIC buses (i.e up to the
limit returned by HAL_IICBuses), but some code accesses the array
without checking against the HAL_IICBuses limit. This causes problems
because the array lives in the SkippedTables area of workspace, meaning
it isn't zero-initialised automatically.

Ensure that the entries for the invalid bus numbers are
zero-initialised, so that code which doesn't check against HAL_IICBuses
won't mistake the invalid entries for valid IRQ-driven buses
(InitialiseIRQ1Vtable, Reset_IRQ_Handler, etc.)

Also, protect against overwriting the end of the array if HAL_IICBuses
is more than the OS supports.

Fixes hang on startup on Pi 4 if memory is filled with -1 (and OS is
told that RAM isn't clear), and on Pi400 with normal memory:
https://www.riscosopen.org/forum/forums/11/topics/16313

Version 6.55. Tagged as 'Kernel-6_55'
parent 7f1f637a
...@@ -9,12 +9,12 @@ ...@@ -9,12 +9,12 @@
GBLS Module_ApplicationDate GBLS Module_ApplicationDate
GBLS Module_HelpVersion GBLS Module_HelpVersion
GBLS Module_ComponentName GBLS Module_ComponentName
Module_MajorVersion SETS "6.54" Module_MajorVersion SETS "6.55"
Module_Version SETA 654 Module_Version SETA 655
Module_MinorVersion SETS "" Module_MinorVersion SETS ""
Module_Date SETS "17 Mar 2021" Module_Date SETS "20 Mar 2021"
Module_ApplicationDate SETS "17-Mar-21" Module_ApplicationDate SETS "20-Mar-21"
Module_ComponentName SETS "Kernel" Module_ComponentName SETS "Kernel"
Module_FullVersion SETS "6.54" Module_FullVersion SETS "6.55"
Module_HelpVersion SETS "6.54 (17 Mar 2021)" Module_HelpVersion SETS "6.55 (20 Mar 2021)"
END END
/* (6.54) /* (6.55)
* *
* This file is automatically maintained by srccommit, do not edit manually. * This file is automatically maintained by srccommit, do not edit manually.
* *
*/ */
#define Module_MajorVersion_CMHG 6.54 #define Module_MajorVersion_CMHG 6.55
#define Module_MinorVersion_CMHG #define Module_MinorVersion_CMHG
#define Module_Date_CMHG 17 Mar 2021 #define Module_Date_CMHG 20 Mar 2021
#define Module_MajorVersion "6.54" #define Module_MajorVersion "6.55"
#define Module_Version 654 #define Module_Version 655
#define Module_MinorVersion "" #define Module_MinorVersion ""
#define Module_Date "17 Mar 2021" #define Module_Date "20 Mar 2021"
#define Module_ApplicationDate "17-Mar-21" #define Module_ApplicationDate "20-Mar-21"
#define Module_ComponentName "Kernel" #define Module_ComponentName "Kernel"
#define Module_FullVersion "6.54" #define Module_FullVersion "6.55"
#define Module_HelpVersion "6.54 (17 Mar 2021)" #define Module_HelpVersion "6.55 (20 Mar 2021)"
#define Module_LibraryVersionInfo "6:54" #define Module_LibraryVersionInfo "6:55"
...@@ -975,8 +975,8 @@ IICInit ...@@ -975,8 +975,8 @@ IICInit
10 10
CallHAL HAL_IICBuses CallHAL HAL_IICBuses
CMP R7, R0 CMP R7, R0
Pull "R7-R9,R14",HS CMPLO R7, #IICBus_Count
BHS IICAbort ; Ensure any CMOS operation aborted BHS %FT30
MOV a1, #0 MOV a1, #0
STR a1, [R8, #IICBus_Status] STR a1, [R8, #IICBus_Status]
MOV a1, R7 MOV a1, R7
...@@ -993,6 +993,18 @@ IICInit ...@@ -993,6 +993,18 @@ IICInit
ADD R8, R8, #IICBus_Size ADD R8, R8, #IICBus_Size
B %BT10 B %BT10
30
; Ensure the remainder is zero-initialised
; (not everything checks against IICBus_Count when looking up buses)
LDR R7, =ZeroPage+IICBus_Base+IICBus_Size*IICBus_Count
MOV R0, #0
40
CMP R7, R8
STRNE R0, [R8], #4
BNE %BT40
Pull "R7-R9,R14"
B IICAbort ; Ensure any CMOS operation aborted
; We need to retain a version of DoMicroDelay with standard calling conventions, because ; We need to retain a version of DoMicroDelay with standard calling conventions, because
; it is called from elsewhere in the kernel. But it can't live inside the protected ; it is called from elsewhere in the kernel. But it can't live inside the protected
; region above in case it's interrupted by a routine that does an IIC operation. ; region above in case it's interrupted by a routine that does an IIC operation.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment