Commit 620ec992 authored by Robert Sprowson's avatar Robert Sprowson
Browse files

Fix some bugs, tidy up a bit

Bugs
- Fix data abort when entering the password at the command prompt, OS_ReadLine with flags in R0 on a 32 bit system treats them as an address
- Correct mode change when sulking to use the right CPSR_c value (was using mode %1111 for ABT32 when should be %10111
Tidying
- no need to use run time checks for 26 or 32 bit now we have sight of No32bitCode and No26bitCode switches
- trim some REM's left over from conversion from BASIC
- escape '$' in resource name
- use read_CMOS function in FSLock_Init
- use selective I cache flush rather than whole world
- use CLRV and SETV macros
- use ASCII_LowerCase macros
Tested in an IOMD ROM, no longer data aborts with FSLock_Unlock command, binary inspected at key sites in a 26 bit version too but not tested.

Version 1.24. Tagged as 'FSLock-1_24'
parent be6a936c
......@@ -11,13 +11,13 @@
GBLS Module_HelpVersion
GBLS Module_ComponentName
GBLS Module_ComponentPath
Module_MajorVersion SETS "1.23"
Module_Version SETA 123
Module_MajorVersion SETS "1.24"
Module_Version SETA 124
Module_MinorVersion SETS ""
Module_Date SETS "25 Sep 2014"
Module_ApplicationDate SETS "25-Sep-14"
Module_Date SETS "26 Sep 2014"
Module_ApplicationDate SETS "26-Sep-14"
Module_ComponentName SETS "FSLock"
Module_ComponentPath SETS "castle/RiscOS/Sources/FileSys/FSLock"
Module_FullVersion SETS "1.23"
Module_HelpVersion SETS "1.23 (25 Sep 2014)"
Module_FullVersion SETS "1.24"
Module_HelpVersion SETS "1.24 (26 Sep 2014)"
END
/* (1.23)
/* (1.24)
*
* This file is automatically maintained by srccommit, do not edit manually.
* Last processed by srccommit version: 1.1.
*
*/
#define Module_MajorVersion_CMHG 1.23
#define Module_MajorVersion_CMHG 1.24
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 25 Sep 2014
#define Module_Date_CMHG 26 Sep 2014
#define Module_MajorVersion "1.23"
#define Module_Version 123
#define Module_MajorVersion "1.24"
#define Module_Version 124
#define Module_MinorVersion ""
#define Module_Date "25 Sep 2014"
#define Module_Date "26 Sep 2014"
#define Module_ApplicationDate "25-Sep-14"
#define Module_ApplicationDate "26-Sep-14"
#define Module_ComponentName "FSLock"
#define Module_ComponentPath "castle/RiscOS/Sources/FileSys/FSLock"
#define Module_FullVersion "1.23"
#define Module_HelpVersion "1.23 (25 Sep 2014)"
#define Module_LibraryVersionInfo "1:23"
#define Module_FullVersion "1.24"
#define Module_HelpVersion "1.24 (26 Sep 2014)"
#define Module_LibraryVersionInfo "1:24"
......@@ -41,15 +41,15 @@ Wsp_FSBlock # 4
Wsp_FS_Open # 4
Wsp_FS_File # 4
Wsp_FS_Func # 4
Wsp_Hard1 # 12 ; REM Name of Hard Drive 1 (Drive 4)
Wsp_Hard2 # 12 ; REM Name of Hard Drive 2 (Drive 5)
Wsp_Hard3 # 12 ; REM Name of Hard Drive 3 (Drive 6)
Wsp_Hard4 # 12 ; REM Name of Hard Drive 4 (Drive 7)
Wsp_CMOSset # 8 ; REM Workspace to copy the CMOS settings into.
Wsp_Passwrd # 4 ; REM Workspace to encrpyt new Password into.
Wsp_Hard1 # 12 ; Name of Hard Drive 1 (Drive 4)
Wsp_Hard2 # 12 ; Name of Hard Drive 2 (Drive 5)
Wsp_Hard3 # 12 ; Name of Hard Drive 3 (Drive 6)
Wsp_Hard4 # 12 ; Name of Hard Drive 4 (Drive 7)
Wsp_CMOSset # 8 ; Workspace to copy the CMOS settings into.
Wsp_Passwrd # 4 ; Workspace to encrpyt new Password into.
Wsp_ScrubStart # 0
Wsp_ReadArg # 256 ; REM OS_ReadArgs workspace.
Wsp_Crypt # 40 ; REM Space for decrypted cryption code
Wsp_ReadArg # 256 ; OS_ReadArgs workspace.
Wsp_Crypt # 40 ; Space for decrypted cryption code
Wsp_ScrubEnd # 0
Wsp_Size # 0
......@@ -149,16 +149,8 @@ init_loop
SWI XMessageTrans_OpenFile
Pull "PC", VS
MOV R0, #OsByte_ReadCMOS
MOV R1, #FSLockCMOS ; Offset into CMOS RAM for data
ADR R3, Wsp_CMOSset
ADD R4, R3, #?FSLockCMOS
init_cmos_loop
SWI XOS_Byte ; Read a byte
STRB R2, [R3], #1 ; Store it in workspace
ADD R1, R1, #1 ; Inc cmos ptr
CMP R3, R4 ; Have we read all the bytes
BLT init_cmos_loop ; If not, loop back
BL read_CMOS
init_claim
MOV R0, #0
STRB R0, Wsp_CMOSset + 6 ; CMOS RAM protection quench off
......@@ -169,7 +161,7 @@ init_claim
Pull "PC"
FSLock_MessageFile
DCB "Resources:$.Resources.FSLock.Messages", 0
DCB "Resources:$$.Resources.FSLock.Messages", 0
ALIGN
; Finalise
......@@ -407,9 +399,9 @@ cs_setnewpassword
MOV R2, #36
BL StringCopy ; Decrypt the crypt routine
MOV R0, #0
MOV R0, #1
ADD R2, R1, R2
SWI XOS_SynchroniseCodeAreas
! 0, "Narrow range?"
LDR R0, [R13, #8]
MOV R14, PC ; Jump to decrypted crypt routine
......@@ -469,9 +461,9 @@ CheckPassword
MOV R2, #36
BL StringCopy ; Decrypt the crypt routine
MOV R0, #0
MOV R0, #1
ADD R2, R1, R2
SWI XOS_SynchroniseCodeAreas
! 0, "Narrow range?"
LDR R0, [R13, #4]
MOV R14, PC
......@@ -816,7 +808,6 @@ write_loop
Pull "R0-R4,PC"
read_CMOS
! 0, "Call this instead of init_cmos_loop"
Push "R0-R4,LR"
MOV R0, #OsByte_ReadCMOS
MOV R1, #FSLockCMOS
......@@ -1026,7 +1017,7 @@ Our_FS_Open
SWI FSLock_Version
MOV R11, R1
Pull "R0,R1,LR"
CMP R0, R0 ; Clear V
CLRV
Push "LR"
BL Check_workspace ; Ensure workspace is okay.
BL Check_R1_path
......@@ -1052,7 +1043,7 @@ Our_FS_File
CMP R0, #fsfile_ReadInfo
LDREQ R11, [R11, #:INDEX:Wsp_FS_File]
BEQ clv_pass_on ; Pass on the call, clearing V
CMP R0, R0 ; Clear V
CLRV
Push "LR"
BL Check_workspace ; Ensure workspace is okay.
BL Check_R1_path
......@@ -1061,7 +1052,7 @@ Our_FS_File
B abort_err
Our_FS_Func
Push "R0-R1,R14"
Push "R0-R1,LR"
Debug diag, "FS_Open", R0, R1
......@@ -1078,7 +1069,7 @@ Our_FS_Func
CMPNE R0, #fsfunc_NameDisc
LDRNE R11, [R11, #:INDEX:Wsp_FS_Func]
BNE clv_pass_on ; Pass on the call, clearing V
CMP R0, R0 ; Clear V
CLRV
Push "R1, LR"
BL Check_workspace ; Ensure workspace is okay.
BL Check_R1_path
......@@ -1090,7 +1081,7 @@ Our_FS_Func
B abort_err
clv_pass_on
CMP R0, R0 ; Clear V
CLRV
MOV PC, R11 ; branch to specified address.
abort_err
......@@ -1172,10 +1163,10 @@ Check_R1_path ROUT
BL String_Compare_CaseInsens
BVS %FT20
10
CMP R0, R0 ; clear V flag
CLRV
Pull "R0-R3,PC"
20
CMP R0, R0 ; clear V flag
CLRV
ADD R1, R1, R2 ; r1 -> next char after end of drive name
Push "R1"
......@@ -1203,10 +1194,9 @@ Check_R1_path ROUT
MOV R2, R3 ; Length
LDR R1, [R13] ; User's
BL StrCmp_CaseInsens
Pull "R1"
ADD R13, R13, #4 ; Junk R1
BVS %BT10
CMP R0,#&80000000 ; sets V perhaps ...
CMNVC R0,#&80000000 ; ensures V set ...
SETV
Pull "R0-R3,PC" ; Unstack registers, exit with V set
DCB "SPTH"
......@@ -1238,12 +1228,18 @@ read_passwd_in ROUT
BL GSWrite0
BVS %FT10
LDR R0, [R13, #0]
ORR R0, R0, #&40000000
MOV R2, #0
MOV R3, #255
MOV R4, #'-'
ASSERT No32bitCode <> No26bitCode ; FSLock is a ROM only module, so can't be both 26/32
[ No32bitCode
ORR R0, R0, #&40000000
SWI XOS_ReadLine
! 0, "Should be ReadLine32"
|
ORR R4, R4, #&40000000
SWI XOS_ReadLine32
]
BVS %FT10
BCS read_gotescape
LDR R0, [R13]
......@@ -1265,7 +1261,7 @@ read_gotescape
; * Scrub
scrub_wkspace ROUT
Push "R0-R2,LR"
MRS R14,CPSR
SavePSR R14
MOV R0, #0 ; Colour to scrub the workspace
ADR R1, Wsp_ScrubStart ; R1 -> Start of area to scrub
ADR R2, Wsp_ScrubEnd ; R2 -> End of area to scrub (+1)
......@@ -1273,16 +1269,15 @@ scrub_wkspace ROUT
STR R0, [R1], #4
CMP R1, R2
BLO %BT10
TEQ PC,PC
Pull "R0-R2,PC",NE,^ ; 26-bit exit OK
MSR CPSR_f, R14
Pull "R0-R2,PC" ; 32-bit exit
RestPSR R14,,f
NOP
Pull "R0-R2,PC"
; * Check workspace
; This will check that the workspace has not been tampered with....
Check_workspace
Push "R0-R4,R12,LR"
MRS R4,CPSR
SavePSR R4
LDR R0, Default_Password
ADRL R1, Module_BaseAddr
ADR R2, CRC_Value
......@@ -1308,10 +1303,9 @@ Check_workspace
Pull "R0-R4,R12,PC", EQ ; Return if workspace is untampered with.
BL ensure_cmos_valid ; Valiate CMOS and workspace settings.
BL Scan_DriveNames ; ReScan the HD names and Store CMOS checksum.
TEQ PC,PC
Pull "R0-R4,R12,PC",NE,^ ; Return to Caller (26-bit exit)
MSR CPSR_f, R4
Pull "R0-R4,R12,PC" ; 32-bit exit
RestPSR R4,,f
NOP
Pull "R0-R4,R12,PC"
; * Get the Hard Drive names to be locked.
; Assumes the ReadArgs buffer can be corrupted.
......@@ -1389,8 +1383,8 @@ Scan_DriveNames ROUT
ASSERT Wsp_Hard4 + ?Wsp_Hard4 = Wsp_CMOSset
MOV R1, #Wsp_CMOSset + 6 - Wsp_Hard1
BL make_checksum ; Get the checksum of the workspace...
ADDS R1, R12, #:INDEX:Wsp_CMOSset + 7 ; clears V
! 0, "ADR+CLRV"
ADR R1, Wsp_CMOSset + 7
CLRV
STRB R0, [R1] ; Store the workspaces copy of its checksum.
Pull "R0-R11,PC"
......@@ -1403,11 +1397,13 @@ Sulk
ADR R0, SulkString
BL GSWrite0
SWI XOS_EnterOS
MSR CPSR_c, #&CF ; Confuse poor dears. Go into ABT32 and lock.
MSR SPSR_c, #&CF ; Set SPSR up for 32-bit exec of next instr.
TEQ PC,PC
TEQNEP PC, #&0BC000003 ; ->SVC26, I,F; or stay in ABT32, I,F.
MOV R0, R0
ASSERT No32bitCode <> No26bitCode ; FSLock is a ROM only module, so can't be both 26/32
[ No32bitCode
WritePSRc F_bit+I_bit+SVC_mode,R0 ; ->SVC26, I,F
|
MSR CPSR_c, #F32_bit+I32_bit+ABT32_mode ; Confuse poor dears. Go into ABT32 and lock.
]
Sulk_Loop
B Sulk_Loop
SulkString
......@@ -1453,18 +1449,17 @@ StringCopy ROUT
SUBS R6, R6, #1 ; Increment counters.
MOVMI R6, #5 ; Reset counter if needed.
CMP R3, R2 ; Have we copied the string?
BLE %BT10 ; Nope. Keep looping.
! 0, "BLT shurley?"
BLT %BT10 ; Nope. Keep looping.
MOV R4, #0
STRB R4, [R1, R3] ; Null terminate copied string.
Pull "R0-R7"
MOV PC, R14 ; Return to Caller. Midnight Caller perhaps?
String_Compare_CaseInsens
String_Compare_CaseInsens ROUT
; Expects strings to be pointed to by R0,R1 & R2 contains length to
; compare them by. Returns with V set if strings are the same.
; R1 must be the non EOR'ed string to compare.
Push "R3-R8"
Push "R3-R8,LR"
MOV R3, #0 ; R0 string index counter.
MOV R6, #5
ADR R7, FSLock_Title ; R7 -> EOR string.
......@@ -1473,32 +1468,18 @@ String_Compare_CaseInsens
LDRB R5, [R1, R3]
LDRB R8, [R7, R6]
EOR R4, R4, R8 ; Decrypt/EOR the char from R0.
CMP R4, #'A'
BLT %FT20
CMP R4, #'Z'
BGT %FT20
ADD R4, R4, #'a' - 'A' ; Convert to lower case.
20
CMP R5, #'A'
BLT %FT30
CMP R5, #'Z'
BGT %FT30
ADD R5, R5, #'a' - 'A' ; Convert to lower case.
30
ASCII_LowerCase R4, R14
ASCII_LowerCase R5, R14
ADD R3, R3, #1 ; Increment string index counter.
CMP R4, R5 ; Are the chars the same?
BNE %FT40 ; No so exit
BNE %FT40 ; No so exit (V clear)
SUBS R6, R6, #1
MOVMI R6, #5
CMP R3, R2 ; Have we finished the compare?
BLT %BT10 ; No so continue
Pull "R3-R8" ; Exit to caller
CMP R0,#&80000000
CMNVC R0,#&80000000
MOV PC,R14
SETV
40
Pull "R3-R8" ; Exit to caller normally.
MOV PC, R14
Pull "R3-R8,PC" ; Exit to caller normally.
rminsert_cmd
DCB "%RMInsert "
......@@ -1508,29 +1489,24 @@ FSLock_Title
FSLock_TitleEnd
ALIGN
StrCmp_CaseInsens
StrCmp_CaseInsens ROUT
; Expects strings to be pointed to by R0,R1 & R2 contains length to
; compare them by. Returns with V set if strings are the same.
Push "R3-R8"
Push "R3-R5,LR"
MOV R3, #0 ; R0 string index counter.
50
LDRB R4, [R0, R3]
LDRB R5, [R1, R3]
CMP R4, #'A'
RSBHSS R8, R4, #'Z'
ADDHS R4, R4, #'a' - 'A' ; Convert to lower case.
CMP R5, #'A'
RSBHSS R8, R5, #'Z'
ADDHS R5, R5, #'a' - 'A' ; Convert to lower case.
ASCII_LowerCase R4, R8
ASCII_LowerCase R5, R8
CMP R4, R5 ; Are the chars the same?
BNE %BT40 ; No so exit
BNE %FT60 ; No so exit
ADD R3, R3, #1 ; Increment string index counter.
CMP R3, R2 ; Have we finished the compare?
BLT %BT50 ; No so continue
Pull "R3-R8" ; Exit to caller
CMP R0,#&80000000
CMNVC R0,#&80000000
MOV PC,R14
SETV
60
Pull "R3-R5,PC" ; Exit to caller normally.
CRC_Value
DCD 0
......
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