Commit 181b8cde authored by Robert Sprowson's avatar Robert Sprowson
Browse files

Drop StoreInHAL switch

No longer support or maintain the code which opened riscos.img and wrote values into it on the Pi.
However, carry over the logic which attempts to restore the time from the timestamp of the CMOS file from last shutdown so that the time (on a clockless Pi) is a better guess than the Unix epoch until the network time can be read.

Tested on a Pi 3.

Version 0.17. Tagged as 'SDCMOS-0_17'
parent 55290078
Dir <Obey$Dir>
amu standalone THROWBACK=-throwback MYASFLAGS="-pd \"StoreInHAL SETL {TRUE}\""
......@@ -11,13 +11,13 @@
GBLS Module_HelpVersion
GBLS Module_ComponentName
GBLS Module_ComponentPath
Module_MajorVersion SETS "0.16"
Module_Version SETA 16
Module_MajorVersion SETS "0.17"
Module_Version SETA 17
Module_MinorVersion SETS ""
Module_Date SETS "03 Aug 2015"
Module_ApplicationDate SETS "03-Aug-15"
Module_Date SETS "15 Oct 2016"
Module_ApplicationDate SETS "15-Oct-16"
Module_ComponentName SETS "SDCMOS"
Module_ComponentPath SETS "cddl/RiscOS/Sources/HWSupport/SD/SDCMOS"
Module_FullVersion SETS "0.16"
Module_HelpVersion SETS "0.16 (03 Aug 2015)"
Module_FullVersion SETS "0.17"
Module_HelpVersion SETS "0.17 (15 Oct 2016)"
END
/* (0.16)
/* (0.17)
*
* This file is automatically maintained by srccommit, do not edit manually.
* Last processed by srccommit version: 1.1.
*
*/
#define Module_MajorVersion_CMHG 0.16
#define Module_MajorVersion_CMHG 0.17
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 03 Aug 2015
#define Module_Date_CMHG 15 Oct 2016
#define Module_MajorVersion "0.16"
#define Module_Version 16
#define Module_MajorVersion "0.17"
#define Module_Version 17
#define Module_MinorVersion ""
#define Module_Date "03 Aug 2015"
#define Module_Date "15 Oct 2016"
#define Module_ApplicationDate "03-Aug-15"
#define Module_ApplicationDate "15-Oct-16"
#define Module_ComponentName "SDCMOS"
#define Module_ComponentPath "cddl/RiscOS/Sources/HWSupport/SD/SDCMOS"
#define Module_FullVersion "0.16"
#define Module_HelpVersion "0.16 (03 Aug 2015)"
#define Module_LibraryVersionInfo "0:16"
#define Module_FullVersion "0.17"
#define Module_HelpVersion "0.17 (15 Oct 2016)"
#define Module_LibraryVersionInfo "0:17"
......@@ -6,7 +6,7 @@
; You may not use this file except in compliance with the Licence.
;
; You can obtain a copy of the licence at
; cddl/RiscOS/Sources/FileSys/SDFS/SDFS/LICENCE.
; cddl/RiscOS/Sources/HWSupport/SD/SDCMOS/LICENCE.
; See the Licence for the specific language governing permissions
; and limitations under the Licence.
;
......@@ -23,11 +23,6 @@
; Use is subject to license terms.
;
[ :LNOT::DEF: StoreInHAL
GBLL StoreInHAL
StoreInHAL SETL {FALSE};
]
GET Hdr:ListOpts
GET Hdr:Macros
GET Hdr:System
......@@ -56,7 +51,7 @@ StoreInHAL SETL {FALSE};
DCD 0 ; Start
DCD Init - |Asm$$Code|
DCD Final - |Asm$$Code|
[ StoreInHAL
[ :LNOT::DEF: StoreAtDiscAddress
DCD Services - |Asm$$Code|
|
DCD 0 ; Service call handler
......@@ -76,18 +71,7 @@ Help = Module_ComponentName, 9, 9, Module_HelpVersion, 0
ALIGN
Flags DCD ModuleFlag_32bit
[ StoreInHAL
NonCanonicalisedPath
= "SDFS:$.!Boot.Loader.riscos/img", 0
NonCanonicalisedPath2
= "SDFS:$.riscos/img", 0
ALIGN
CMOSMarker UND #&C305
OSIm = "OSIm"
ELIF :LNOT::DEF: StoreAtDiscAddress
[ :LNOT::DEF: StoreAtDiscAddress
NonCanonicalisedPath
= "SDFS:$.CMOS", 0
......@@ -100,13 +84,12 @@ SaveCMOS
Len_SaveCMOS * .-SaveCMOS
ALIGN
]
]
ReqdAPIMajor * 0
Init ROUT
Entry
[ :LNOT: StoreInHAL
; If the HAL proclaims hardware CMOS is present, go dormant
MOV r6, r8
MOV r1, #0
......@@ -135,7 +118,7 @@ Init ROUT
MakeInternatErrorBlock HardwareDepends,,HWDep
30
MOV r8, r6
]
; This module is designed to be included in a ROM, in which case we have
; to take account of the fact that SDFS::0 isn't properly initialised
; until the callbacks after ROM init.
......@@ -192,7 +175,7 @@ CallBackFromInit ROUT
99
[ :LNOT::DEF: StoreAtDiscAddress
[ :LNOT::DEF: StoreAtDiscAddress
; In: r1 = filename
; Out: Regs corrupt
; V set on failure
......@@ -208,30 +191,22 @@ TryInit ROUT
SWI XOS_FSControl
BVS %F90
[ StoreInHAL
; Allocate a buffer to hold filename of the ROM image plus terminator
RSB r3, r5, #1
|
; Allocate a buffer for the command string - will contain "SaveCMOS "
; plus the canonicalised name of the file, plus a terminator
RSB r3, r5, #Len_SaveCMOS + 1
]
MOV r0, #ModHandReason_Claim
SWI XOS_Module
BVS %F90
STR r2, [r12]
; Get the canonicalised name
[ :LNOT: StoreInHAL
ADD r2, r2, #Len_SaveCMOS
]
MOV r5, r3
MOV r0, #FSControl_CanonicalisePath
MOV r3, #0
SWI XOS_FSControl
BVS %F90
[ :LNOT: StoreInHAL
; Copy in the "SaveCMOS " part now we have a few more working registers
ASSERT Len_SaveCMOS = 9
SUB r2, r2, #Len_SaveCMOS
......@@ -240,7 +215,6 @@ TryInit ROUT
LDRB r6, [r3]
STMIA r2!, {r4-r5}
STRB r6, [r2], #1
]
; Check it's a file (or image file)
MOV r0, #OSFile_ReadWithTypeNoPath
......@@ -250,14 +224,23 @@ TryInit ROUT
TST r0, #object_file
BEQ %F90
[ :LNOT: StoreInHAL
; Check it's a sensible filetype
LDR r0, =FileType_Configuration
TEQ r6, r0
LDRNE r0, =FileType_MSDOS
TEQNE r6, r0
BNE %F90
|
; If there's no RTC, try restoring the time from the file timestamp
SWI XRTC_Features
BVC %F80 ; V clear -> RTC driver is active
AND r4, r2, #&FF
ORRS r0, r4, r3
BEQ %F80 ; Clearly duff load/exec address (timestamp)
Push "r3-r4"
; If the time is in 1970 then the kernel didn't find a real time
; clock, and NetTime hasn't picked up a link yet
SUB sp, sp, #8
......@@ -267,7 +250,7 @@ TryInit ROUT
MOV r1, sp
SWI XOS_Word
ADDVS sp, sp, #8
BVS %F80
BVS %F60
LDR r3, =((71 * 365) + 18) * 86400
MOV r0, #100 ; want cs to end of 1970 from epoch 1900
......@@ -276,66 +259,16 @@ TryInit ROUT
LDRB r1, [sp, #4]
SUBS r14, r0, r3
SBCS r14, r1, r4
ADDPL sp, sp, #8 ; now > 1970
BPL %F80
ADD sp, sp, #8
BPL %F60 ; now > 1970
; Try and find the last saved value
MOV r0, #open_read :OR: open_mustopen :OR: open_nodir :OR: open_nopath
LDR r1, [r12]
SWI XOS_Find
BVS %F70
MOV r1, r0
; Search for the CMOS in the ROM on disc
LDR r5, CMOSMarker
LDR r6, OSIm
MOV r0, #OSGBPB_ReadFromPTR
50 MOV r2, sp
MOV r3, #4
SWI XOS_GBPB
BVS %F60
LDR r14, [sp]
TEQ r14, r6
BEQ %F60 ; got to the end of the HAL and not found CMOS - give up
TEQ r14, r5
BNE %B50
; Read size of pseudo CMOS in HAL
MOV r2, sp
MOV r3, #4
SWI XOS_GBPB
BVS %F60
LDR r6, [sp]
; If there's no RTC, try restoring the time from the HAL timestamp
SWI XRTC_Features
BVC %F60 ; V clear -> RTC driver is active
; Read the last timestamp
MOV r0, #OSGBPB_ReadFromGiven
MOV r2, sp
MOV r3, #5
ADD r4, r4, r6
SWI XOS_GBPB
BVS %F60
; Check it's not unset
LDR r3, [sp, #0]
LDRB r4, [sp, #4]
ORRS r3, r4, r3
MOVNE r0, sp
SWINE XTerritory_SetTime
; Use load/exec address (timestamp) as a better guess
MOV r0, sp
SWI XTerritory_SetTime
CLRV
60
MRS r3, CPSR ; preserve V set ness
MOV r0, #0 ; close file
SWI XOS_Find
MSR CPSR_f, r3
70
ADD sp, sp, #8 ; skip temp block
BVS %F90
ADD sp, sp, #8 ; Drop load/exec address
80
]
; All good
CLRV
EXIT
......@@ -351,17 +284,16 @@ TryInit ROUT
STR r2, [r12]
SETV
EXIT
] ; :LNOT::DEF: StoreAtDiscAddress
[ StoreInHAL
Services ROUT
TEQ r1, #Service_ShutDown
MOVNE pc, lr
Push "r0, lr" ; keep original r0 in case MyByteV returns an error
Push "pc"
BL %FT15 ; now write the values out, along with the timestamp
NOP
Pull "r0, pc" ; and on with the shutdown (don't claim)
Push "r0-r1, lr" ; keep original r0 in case OS_File returns an error
LDR r1, [r12]
ADD r1, r1, #Len_SaveCMOS
MOV r0, #OSFile_SetStamp
SWI XOS_File ; stamp at shutdown so file timestamp is fresh
Pull "r0-r1, pc" ; and on with the shutdown (don't claim)
]
MyByteV
......@@ -397,75 +329,6 @@ MyByteV
ADD sp, sp, r6
STRVS r0, [sp]
Pull "r0-r4,r6, pc" ; go to original claim address
ELIF StoreInHAL
15
Push "r0-r7"
SUB sp, sp, #4 ; allocate space on stack for buffer
MOV r7, r1
MOV r0, #open_update :OR: open_mustopen :OR: open_nodir :OR: open_nopath
LDR r1, [r12]
SWI XOS_Find
BVS %F90
MOV r1, r0
; Search for the CMOS in the ROM on disc - can't be sure it matches the
; running version!
LDR r5, CMOSMarker
LDR r6, OSIm
MOV r0, #OSGBPB_ReadFromPTR
20 MOV r2, sp
MOV r3, #4
SWI XOS_GBPB
BVS %F80
LDR r14, [sp]
TEQ r14, r6
BEQ %F80 ; got to the end of the HAL and not found CMOS - give up
TEQ r14, r5
BNE %B20
; Read size of block in HAL
MOV r2, sp
MOV r3, #4
SWI XOS_GBPB
BVS %F80
LDR r6, [sp]
MOV r5, r1 ; keep file handle safe
BL CMOSToStack
; Overwrite the HAL with the block from the stack
MOV r0, #OSGBPB_WriteAtPTR
MOV r1, r5
MOV r2, sp
MOV r3, r6
SWI XOS_GBPB
BVS %F75
; Refresh the timestamp
MOV r0, #OsWord_ReadRealTimeClock
MOV r1, #OWReadRTC_5ByteInt
STRB r1, [sp]
MOV r1, sp
SWI XOS_Word
MOVVC r0, #OSGBPB_WriteAtPTR
MOVVC r1, r5
MOVVC r2, sp
MOVVC r3, #5
SWIVC XOS_GBPB
75
ADD sp, sp, r6
80 MOV r2, r0 ; preserve the original error
MRS r3, CPSR
MOV r0, #0 ; close file
SWI XOS_Find
MOV r0, r2
MSR CPSR_f, r3
90 ADD sp, sp, #4 ; skip temp block
STRVS r0, [sp]
Pull "r0-r7, pc" ; go to original claim address
|
Push "r0"
LDR r0, [r12]
......@@ -474,7 +337,7 @@ MyByteV
Pull "r0, pc" ; go to original claim address
]
[ StoreInHAL :LOR: :DEF: StoreAtDiscAddress
[ :DEF: StoreAtDiscAddress
CMOSToStack ROUT
MOV r4, lr
; Copy the CMOS RAM into a block on the stack (should be small enough)
......
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