Commit 2ad3fd32 authored by Robert Sprowson's avatar Robert Sprowson
Browse files

Add support for 'PostDesk' shutdown scripts

Useful for small clearup activities on each shutdown. As we're trying to shut down the range of things looked for is very small compared with the PreDesk directory: no sprites, no apps (or directories), no utilities, no BASIC, no modules. Keep it simple and fast!
* If Choices:Boot.PostDesk is present, any obey files within it are obey'd
* Swap false/true to {FALSE} and {TRUE}
* TaskManager_Shutdown flag bit 7 can skip the shutdown scripts
* Simplified evaluation of Boot$OSVersion
* Changed pre RISC OS 3.50 reset to actually do a reset rather than just reenter the desktop
* Shared a few constant strings

Version 1.37. Tagged as 'Switcher-1_37'
parent 46fe0819
......@@ -11,13 +11,13 @@
GBLS Module_HelpVersion
GBLS Module_ComponentName
GBLS Module_ComponentPath
Module_MajorVersion SETS "1.36"
Module_Version SETA 136
Module_MajorVersion SETS "1.37"
Module_Version SETA 137
Module_MinorVersion SETS ""
Module_Date SETS "28 Jul 2012"
Module_ApplicationDate SETS "28-Jul-12"
Module_Date SETS "29 Jul 2012"
Module_ApplicationDate SETS "29-Jul-12"
Module_ComponentName SETS "Switcher"
Module_ComponentPath SETS "castle/RiscOS/Sources/Desktop/Switcher"
Module_FullVersion SETS "1.36"
Module_HelpVersion SETS "1.36 (28 Jul 2012)"
Module_FullVersion SETS "1.37"
Module_HelpVersion SETS "1.37 (29 Jul 2012)"
END
/* (1.36)
/* (1.37)
*
* This file is automatically maintained by srccommit, do not edit manually.
* Last processed by srccommit version: 1.1.
*
*/
#define Module_MajorVersion_CMHG 1.36
#define Module_MajorVersion_CMHG 1.37
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 28 Jul 2012
#define Module_Date_CMHG 29 Jul 2012
#define Module_MajorVersion "1.36"
#define Module_Version 136
#define Module_MajorVersion "1.37"
#define Module_Version 137
#define Module_MinorVersion ""
#define Module_Date "28 Jul 2012"
#define Module_Date "29 Jul 2012"
#define Module_ApplicationDate "28-Jul-12"
#define Module_ApplicationDate "29-Jul-12"
#define Module_ComponentName "Switcher"
#define Module_ComponentPath "castle/RiscOS/Sources/Desktop/Switcher"
#define Module_FullVersion "1.36"
#define Module_HelpVersion "1.36 (28 Jul 2012)"
#define Module_LibraryVersionInfo "1:36"
#define Module_FullVersion "1.37"
#define Module_HelpVersion "1.37 (29 Jul 2012)"
#define Module_LibraryVersionInfo "1:37"
......@@ -36,7 +36,7 @@ SWIClass SETS SwitcherSWI_Name
AddSWI TaskNameFromHandle
AddSWI EnumerateTasks
AddSWI Shutdown ; Switcher 0.60 onwards
AddSWI StartTask
AddSWI StartTask ; Switcher 1.10 onwards
; Flags for Shutdown SWI
......@@ -47,7 +47,7 @@ shutdownbit_SendShutdownMessage * 1:SHL:3 ; Switcher 0.62 onwards
shutdownbit_RejectMediaSearch * 1:SHL:4
shutdownbit_ExitAndRestart * 1:SHL:5 ; Switcher 1.36 onwards
shutdownbit_ExitAndPowerOff * 1:SHL:6
shutdownbit_NoPostDeskScripts * 1:SHL:7
shutdownbit_NoPostDeskScripts * 1:SHL:7 ; Switcher 1.37 onwards
OPT OldOpt
......
......@@ -83,7 +83,7 @@ SlowPollIfNoDrag SETL {TRUE}
OldRAMFS SETL {TRUE}
GBLL ProvideStartTask
ProvideStartTask SETL {TRUE} ; Include TaskManager_StartTask SWI?
ProvideStartTask SETL {TRUE} ; Include TaskManager_StartTask SWI?
GBLL KeyTasks ; Respond to hotkey events according to Key$... system variables
KeyTasks SETL {TRUE}
......@@ -102,7 +102,7 @@ Module_BaseAddr
GBLL hostvdu
hostvdu SETL true
hostvdu SETL {TRUE}
GBLL debug
GBLL debugxx
......@@ -112,17 +112,16 @@ hostvdu SETL true
GBLL debugin
GBLL debugmn
GBLL debugif
GBLL debugkey
debug SETL false
debugxx SETL false ; misc bits
debugsw SETL false ; SWIs
debugab SETL false ; Auto boot settings
debugsh SETL false ; shutdown and restart bits
debugin SETL false ; internationalisation bits
debugmn SETL false ; menu handling
debugif SETL false ; info box bits
debugkey SETL false
GBLL debugky
debug SETL {FALSE}
debugxx SETL debug :LAND: {FALSE} ; misc bits
debugsw SETL debug :LAND: {FALSE} ; SWIs
debugab SETL debug :LAND: {FALSE} ; Auto boot settings
debugsh SETL debug :LAND: {FALSE} ; shutdown and restart bits
debugin SETL debug :LAND: {FALSE} ; internationalisation bits
debugmn SETL debug :LAND: {FALSE} ; menu handling
debugif SETL debug :LAND: {FALSE} ; info box bits
debugky SETL debug :LAND: {FALSE} ; captured keys
^ 1
! 0, "FIXME: Error base of 1!"
......@@ -404,7 +403,7 @@ flg_nothing * 0
flg_exit * 1
flg_shutdown * 2
; icon handler in "proginfo" dbox
; icon handles in "proginfo" dbox
proginfo_author * 2
proginfo_version * 3
......@@ -1536,14 +1535,8 @@ Die
taskidentifier DCB "TASK"
;;----------------------------------------------------------------------------
;; Entry point
;;----------------------------------------------------------------------------
ASSERT ((.-Module_BaseAddr):AND:3)=0
wn_switcher DCB "taskmenu",0
ALIGN
wn_switcher DCB "taskmenu",0 ; must be word-aligned
ALIGN
wn_grabkeys DCB "grabkeys",0 ; must be word-aligned
......@@ -1561,15 +1554,14 @@ wn_shutdown DCB "shutdown",0 ; must be word-aligned
ALIGN
wn_powrdown DCB "powrdown",0 ; must be word-aligned
]
ALIGN
wn_powerdown DCB "power",0 ; must be word-aligned
str_boot DCB "!Boot",0
str_altboot DCB "<Choices$Write>.Boot.Tasks",0
str_altbootfn DCB "<Choices$Write>.Boot.Tasks.!Boot",0
str_altbootfn DCB "<Choices$Write>.Boot.Tasks." ; share name with str_boot
str_boot DCB "!Boot",0
templatefname DCB "Switcher:Templates",0 ; relies on Wimp$Path ; AMcC 18-Oct-94 changed from Template3D
templatefname DCB "Switcher:Templates",0 ; relies on Switcher$Path
switchertitle DCB "task",0
ALIGN
......@@ -1589,6 +1581,12 @@ MessagesList DCD Message_HelpRequest
DCD 0
ALIGN
;;----------------------------------------------------------------------------
;; Entry point
;;----------------------------------------------------------------------------
ASSERT ((.-Module_BaseAddr):AND:3)=0
Start LDR wp, [r12] ; get workspace pointer
MOV sp, #-1 ; ensure stack pointer is invalid
......@@ -1676,26 +1674,12 @@ Start LDR wp, [r12] ; get workspace pointer
STRB r1, soft_poweroff
ADR r0, bootosstring
MVN r2, #0
MOV r3, #0
MOV r4, #VarType_Expanded
SWI XOS_ReadVarVal
TEQ r2, #0
BEQ %FT09 ; no variable,so the boot failed - reject configuration
MVN r2, r2
ADD r5, r2, #3
BIC r5, r5, #3 ; round up to nearest word
SUB r13, r13, r5
ADR r0, bootosstring
MOV r1, r13
MOV r3, #0
SWI XOS_ReadVarVal
MOV r0, #10 ; base 10 please
SWI XOS_ReadUnsigned
ADD r13, r13, r5
MOVVS r2, #0
09
STR r2,bootosversion ; decides where we look for configure
MOV r2, #0
SWI XOS_EvaluateExpression
MVNVS r1, #0
MOVS r1, r1
MOVNE r2, #0 ; no variable or not a number, so the boot failed
STR r2,bootosversion ; decides where we look for !Configure
;
; read window definitions from template file
......@@ -1777,23 +1761,25 @@ Start LDR wp, [r12] ; get workspace pointer
ADRL R14,mb_savedbox
STR R1,[R14]
[ {TRUE}
[ {TRUE}
Push "R0-R1,R3-R5"
MOV R0,#OSFile_ReadNoPath
ADRL R1,str_altboot
ADRL R1,str_altboot ; preferred location for saving desktop settings
SWI XOS_File
BVS %FT00
TEQ R0,#2
TEQ R0,#object_directory
BNE %FT00
ADRL R2,str_altbootfn
ADRL R2,str_altbootfn ; full path for saving desktop settings
Pull "R0-R1,R3-R5"
B %FT01
00
CLRV
Pull "R0-R1,R3-R5"
]
]
ADRL R2,str_boot
01 LDRB R14,[R2],#1 ; copy in appropriate boot filename
01 LDRB R14,[R2],#1 ; copy in appropriate desktop boot filename
STRB R14,[R1],#1
TEQ R14,#0
BNE %BT01
......@@ -1971,7 +1957,7 @@ com_unset DCB "%Unset SaveDesk$File", 0
icondef DCD &D7006002 ; flags
DCB "taskmanager",0
bootosstring DCB "Boot$OSVersion",0
bootosstring DCB "<Boot$OSVersion>",0
ALIGN
ErrorCloseTemplate
......@@ -3330,6 +3316,27 @@ doexitbits
doshutdown
SWI XHourglass_On ; ensure switched HourGlass on
LDR R0,shutdownflags ; skip scripts?
TST R0,#shutdownbit_NoPostDeskScripts
BNE %FT10
MOV R0,#OSFile_ReadNoPath
ADRL R1,str_postpath
SWI XOS_File
BVS %FT10
TEQ r0, #object_directory ; check for a 'PostDesk' directory present
BNE %FT10
Debug xx,"Running PostDesk scripts"
ADR R0,str_postset ; set minimal aliases, run any scripts (before the *SHUTDOWN
SWI XOS_CLI ; command so the drive isn't left mounted), then unset aliases
BVS %FT10
ADR R0,str_postdesk
SWI XOS_CLI
ADR R0,str_postunset
SWI XOS_CLI
10
ADR R0,str_shutdown
SWI XOS_CLI ; ignore errors
......@@ -3404,29 +3411,33 @@ doshutdown
Pull "PC" ; just loop to ensure redraw!
str_shutdown DCB "WimpTask ShutDown", 0
str_postdesk DCB "WimpTask Repeat BootObey " ; continues...
str_postpath DCB "Choices:Boot.PostDesk -type Obey", 0 ; OSFile_ReadNoPath accepts spaces as terminators
str_postset DCB "Set Alias$BootObey Obey -c %*0", 0
ALIGN
str_restart DCB "Desktop -File <Desktop$File>", 0
str_restart1 DCB "Desktop",0
restart_varname DCB "Desktop$File",0
str_postunset DCB "Unset Alias$BootObey", 0
ALIGN
restart BL freeworkspace
;..............................................................................
restart
BL freeworkspace
SWI XOS_Reset ; on RISC OS 3.5 and above, do total reset
CLRV
SWI XOS_Reset ; on RISC OS 3.5 and above, do simple reset
ADR r0,restart_varname
MOV r2,#-1
MOV r3,#0
MOV r4,#VarType_Expanded
SWI XOS_ReadVarVal
MOV r1, #Service_PreReset
SWI XOS_ServiceCall
CMP r2,#0
ADRNE r0,str_restart
ADREQ r0,str_restart1
SWI XOS_CLI ; ignore errors
SWI OS_Exit
MOV r0, #OsByte_RW_BreakEscapeAction
MOV r1, #2 ; do memory clear
MOV r2, #0
SWI XOS_Byte
SWI XOS_EnterOS
TEQP PC, #I_bit :OR: F_bit :OR: SVC_mode
MOV r0, #&03800000
LDR r1, [r0]
STR r1, [r0, -r0] ; poke reset address from ROM to vectors
MOV PC, #0 ; jeronimo
;..............................................................................
[ PowerDownReset
......@@ -3434,8 +3445,8 @@ powerdown
LDR r0, =PowerDownMagic
SWI OS_Reset ; turn off
]
;..............................................................................
;..............................................................................
done_prequit
ADR R1,msg_quit
LDR R2,quitreceiver ; broadcast / single task
......@@ -4718,8 +4729,7 @@ null_event ROUT
LDRB R0,[R0,R14] ; R0 = dynamic area number
LDR R14,[userblk,#icb_memsize]
; NK 0.80 check max size of area
[ false
[ :LNOT:readareas
Push "R0-R2,R14"
ORR R0,R0,#128 ; want max size, nb. if DDA's come through here
; then do cmp with 256.
......@@ -5345,7 +5355,7 @@ key_pressed
LDR R0,[R1,#wc_char] ; R0 = key code
Debug key,"Task Manager Received key ",R0
Debug ky,"Task Manager Received key ",R0
LDR R3,[R1,#wc_handle] ; don't corrupt R2
LDR R14,h_savedbox
......@@ -5517,7 +5527,7 @@ click_menu
TST R4,#if_text
TSTNE R4,#if_indirected ; are the flags valid?
MOVEQ R0,#-1
[ false
[ {FALSE}
LDRNE R0,[R1,#gi_iconblock +i_data +ii_buffer]
LDRNEB R0,[R0,R3] ; get the character
BICNE R0,R0,#32 ; ensure lowercase
......@@ -5529,11 +5539,11 @@ click_menu
TEQ R0,R3 ; are they correct
ADDEQ R2,R2,#1 ; if they are then increase the index
MOVNE R2,#-1
|
|
LDRNEB R2,keycount
ADDNE R2,R2,#1
MOVEQ R2,#-1
]
]
STRB R2,keycount ; increase until all read
;
TEQ R2,#?keys
......@@ -6601,7 +6611,7 @@ CopyMenus Entry "r1-r7"
LDR r1, bootosversion
TEQ r1, #0 ; no boot$osversion?,no configure then
MOVEQ r0, r1
MOVEQ r0, #object_nothing
BEQ %FT09
LDR r2, =350
CMP r1, r2
......@@ -6612,7 +6622,7 @@ CopyMenus Entry "r1-r7"
09
LDR r14, mm_config + 8
ORRVS r14, r14, #is_shaded
TEQ r0, #2
TEQ r0, #object_directory
ORRNE r14, r14, #is_shaded
BICEQ r14, r14, #is_shaded ; directory was found
STR r14, mm_config + 8
......
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