ModHead 23.5 KB
Newer Older
Neil Turton's avatar
Neil Turton committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
; Copyright 1996 Acorn Computers Ltd
;
; Licensed under the Apache License, Version 2.0 (the "License");
; you may not use this file except in compliance with the License.
; You may obtain a copy of the License at
;
;     http://www.apache.org/licenses/LICENSE-2.0
;
; Unless required by applicable law or agreed to in writing, software
; distributed under the License is distributed on an "AS IS" BASIS,
; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
; See the License for the specific language governing permissions and
; limitations under the License.
;
; > s.ModHead

        ASSERT  (.=Module_BaseAddr)

MySWIBase       *       Module_SWISystemBase + FilterSWI * Module_SWIChunkSize

        DCD     0                 ;Start - Module_BaseAddr
        DCD     Init              - Module_BaseAddr
        DCD     Die               - Module_BaseAddr
        DCD     Service           - Module_BaseAddr
        DCD     Title             - Module_BaseAddr
        DCD     Helpstr           - Module_BaseAddr
        DCD     Helptable         - Module_BaseAddr
        DCD     MySWIBase
        DCD     Filter_SWIdecode  - Module_BaseAddr
        DCD     Filter_SWInames   - Module_BaseAddr
        DCD     0
32
      [ international_help
Neil Turton's avatar
Neil Turton committed
33
        DCD     message_file_name - Module_BaseAddr
34
      |
Neil Turton's avatar
Neil Turton committed
35
        DCD     0
36
      ]
37
      [ :LNOT: No32bitCode
Stewart Brodie's avatar
Stewart Brodie committed
38
        DCD     ModuleFlags       - Module_BaseAddr
39
      ]
Neil Turton's avatar
Neil Turton committed
40 41 42

; ----------------------------------------------------------------------------------------------------------------------
Title   DCB     "FilterManager",0
43
Helpstr DCB     "Filter Manager",9,"$Module_HelpVersion"
Robert Sprowson's avatar
Robert Sprowson committed
44
        DCB     0
45 46
        ALIGN

Neil Turton's avatar
Neil Turton committed
47 48 49 50
; ----------------------------------------------------------------------------------------------------------------------

prefilter_token         DCB     "PreFT",0
postfilter_token        DCB     "PostFT",0
Kevin Bracey's avatar
Kevin Bracey committed
51 52
rectfilter_token        DCB     "RectFT",0
copyfilter_token        DCB     "CopyFT",0
Robert Sprowson's avatar
Robert Sprowson committed
53
postrectfilter_token    DCB     "PostRectFT",0
Kevin Bracey's avatar
Kevin Bracey committed
54
posticonfilter_token    DCB     "PostIconFT",0
Neil Turton's avatar
Neil Turton committed
55 56 57 58 59 60
filter_token            DCB     "Filter",0
task_token              DCB     "Task",0
mask_token              DCB     "Mask",0
all_token               DCB     "All",0
                        ALIGN

61 62 63
      [ :LNOT: No32bitCode
ModuleFlags             DCD     ModuleFlag_32bit
      ]
Stewart Brodie's avatar
Stewart Brodie committed
64

Neil Turton's avatar
Neil Turton committed
65
min_gap         *       3
66 67 68
min_tab1        *       20
min_tab2        *       24
min_tab3        *       8
Neil Turton's avatar
Neil Turton committed
69 70 71 72

; ---------------------------------------------------------------------------------------------------------------------
;       Handle *Filters - List all attached filters with the tasks they are attached to.
Filters_Code
73
        Push    "r7-r9,LR"
Robert Sprowson's avatar
Robert Sprowson committed
74
        Debug   xx,"*Filters called, listing filters"
Neil Turton's avatar
Neil Turton committed
75

Robert Sprowson's avatar
Robert Sprowson committed
76
        LDR     wp,[R12]
Neil Turton's avatar
Neil Turton committed
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99

        MOV     r4, #0                  ; r4 = how much space we are using on the stack to hold column headings.

        ADR     r1, filter_token
        BL      lookuptostack
        BVS     %FT05
        STR     sp, filter_text
        ADD     r5, r3, #min_gap        ; r5 = width of column 1
        CMP     r5, #min_tab1
        MOVCC   r5, #min_tab1

        ADR     r1, task_token
        BL      lookuptostack
        BVS     %FT05
        STR     sp, task_text
        ADD     r6, r3, #min_gap        ; r6 = width of column 2
        CMP     r6, #min_tab2
        MOVCC   r6, #min_tab2

        ADR     r1, mask_token
        BL      lookuptostack
        BVS     %FT05
        STR     sp, mask_text
100 101 102
        ADD     r7, r3, #min_gap        ; r7 = width of column 3
        CMP     r7, #min_tab3
        MOVCC   r7, #min_tab3
Neil Turton's avatar
Neil Turton committed
103 104 105 106 107 108

        ADR     r1, all_token
        BL      lookuptostack
        BVS     %FT05
        STR     sp, all_text

109 110 111 112
        ; pre filters
        MOV     r0, #2_011
        ADR     r1, prefilter_token
        BL      writeheadings
Neil Turton's avatar
Neil Turton committed
113 114 115
        BVS     %FT05

        LDR     r3, pre_filters
116
        B       %FT08
Neil Turton's avatar
Neil Turton committed
117
01
118 119 120 121
        LDR     r9, [r3, #f_task]
        TST     r9, #f_task_quit
        BNE     %FT03                   ; Mute this one, the specific task has quit

Neil Turton's avatar
Neil Turton committed
122 123 124 125 126
        LDR     r0, [r3, #f_name]
        MOV     r1, r5
        BL      writefield
        BVS     %FT05

127 128 129
        MOV     r0, r9
        BL      writetaskname
        SWIVC   XOS_NewLine
Neil Turton's avatar
Neil Turton committed
130
        BVS     %FT05
131
03
Neil Turton's avatar
Neil Turton committed
132
        LDR     r3, [r3, #next_ptr]
133
08
Neil Turton's avatar
Neil Turton committed
134 135 136 137 138 139
        CMP     r3, #0
        BNE     %BT01

        SWI     XOS_NewLine
        BVS     %FT05

140 141 142 143
        ; post filters
        MOV     r0, #2_111
        ADRL    r1, postfilter_token
        BL      writeheadings
Neil Turton's avatar
Neil Turton committed
144 145 146
        BVS     %FT05

        LDR     r3, post_filters
147 148 149 150 151 152
        B       %FT18
11
        LDR     r9, [r3, #f_task]
        TST     r9, #f_task_quit
        BNE     %FT13                   ; Mute this one, the specific task has quit

Neil Turton's avatar
Neil Turton committed
153 154 155 156 157
        LDR     r0, [r3, #f_name]
        MOV     r1, r5
        BL      writefield
        BVS     %FT05

158 159
        MOV     r0, r9
        BL      writetaskname
Neil Turton's avatar
Neil Turton committed
160 161 162 163
        BVS     %FT05

        LDR     r0, [r3, #f_mask]
        ADR     r1, convert_buffer
164
        MOV     r2, #?convert_buffer
Neil Turton's avatar
Neil Turton committed
165 166 167 168
        SWI     XOS_ConvertHex8
        SWIVC   XOS_Write0
        SWIVC   XOS_NewLine
        BVS     %FT05
169
13
Neil Turton's avatar
Neil Turton committed
170
        LDR     r3, [r3, #next_ptr]
171
18
Neil Turton's avatar
Neil Turton committed
172
        CMP     r3, #0
173
        BNE     %BT11
Kevin Bracey's avatar
Kevin Bracey committed
174

Robert Sprowson's avatar
Robert Sprowson committed
175 176
        SWI     XOS_NewLine
        BVS     %FT05
Kevin Bracey's avatar
Kevin Bracey committed
177

178 179
        ; rect filters
        MOV     r0, #2_011
Kevin Bracey's avatar
Kevin Bracey committed
180
        ADRL    r1, rectfilter_token
181
        BL      writeheadings
Kevin Bracey's avatar
Kevin Bracey committed
182 183 184
        BVS     %FT05

        LDR     r3, rect_filters
185 186 187 188 189
        B       %FT28
21
        LDR     r9, [r3, #f_task]
        TST     r9, #f_task_quit
        BNE     %FT23                   ; Mute this one, the specific task has quit
Kevin Bracey's avatar
Kevin Bracey committed
190 191 192 193 194 195

        LDR     r0, [r3, #f_name]
        MOV     r1, r5
        BL      writefield
        BVS     %FT05

196 197
        MOV     r0, r9
        BL      writetaskname
Kevin Bracey's avatar
Kevin Bracey committed
198
        BVS     %FT05
199
23
Kevin Bracey's avatar
Kevin Bracey committed
200
        LDR     r3, [r3, #next_ptr]
201
28
Kevin Bracey's avatar
Kevin Bracey committed
202
        CMP     r3, #0
203
        BNE     %BT21
Kevin Bracey's avatar
Kevin Bracey committed
204 205

        SWI     XOS_NewLine
Robert Sprowson's avatar
Robert Sprowson committed
206
        BVS     %FT05
Kevin Bracey's avatar
Kevin Bracey committed
207

208 209
        ; post rect filters
        MOV     r0, #2_011
Kevin Bracey's avatar
Kevin Bracey committed
210
        ADRL    r1, postrectfilter_token
211
        BL      writeheadings
Kevin Bracey's avatar
Kevin Bracey committed
212 213 214
        BVS     %FT05

        LDR     r3, post_rect_filters
215 216 217 218 219
        B       %FT38
31
        LDR     r9, [r3, #f_task]
        TST     r9, #f_task_quit
        BNE     %FT33                   ; Mute this one, the specific task has quit
Kevin Bracey's avatar
Kevin Bracey committed
220 221 222 223 224 225

        LDR     r0, [r3, #f_name]
        MOV     r1, r5
        BL      writefield
        BVS     %FT05

226 227
        MOV     r0, r9
        BL      writetaskname
Kevin Bracey's avatar
Kevin Bracey committed
228 229
        SWIVC   XOS_NewLine
        BVS     %FT05
230
33
Kevin Bracey's avatar
Kevin Bracey committed
231
        LDR     r3, [r3, #next_ptr]
232
38
Kevin Bracey's avatar
Kevin Bracey committed
233
        CMP     r3, #0
234
        BNE     %BT31
Kevin Bracey's avatar
Kevin Bracey committed
235 236

        SWI     XOS_NewLine
Robert Sprowson's avatar
Robert Sprowson committed
237
        BVS     %FT05
Kevin Bracey's avatar
Kevin Bracey committed
238

239 240
        ; post icon filters
        MOV     r0, #2_011
Kevin Bracey's avatar
Kevin Bracey committed
241
        ADRL    r1, posticonfilter_token
242
        BL      writeheadings
Kevin Bracey's avatar
Kevin Bracey committed
243 244 245
        BVS     %FT05

        LDR     r3, post_icon_filters
246 247 248 249 250
        B       %FT48
41
        LDR     r9, [r3, #f_task]
        TST     r9, #f_task_quit
        BNE     %FT43                   ; Mute this one, the specific task has quit
Kevin Bracey's avatar
Kevin Bracey committed
251 252 253 254 255 256

        LDR     r0, [r3, #f_name]
        MOV     r1, r5
        BL      writefield
        BVS     %FT05

257 258
        MOV     r0, r9
        BL      writetaskname
Kevin Bracey's avatar
Kevin Bracey committed
259 260
        SWIVC   XOS_NewLine
        BVS     %FT05
261
43
Kevin Bracey's avatar
Kevin Bracey committed
262
        LDR     r3, [r3, #next_ptr]
263
48
Kevin Bracey's avatar
Kevin Bracey committed
264
        CMP     r3, #0
265
        BNE     %BT41
Kevin Bracey's avatar
Kevin Bracey committed
266 267

        SWI     XOS_NewLine
Robert Sprowson's avatar
Robert Sprowson committed
268
        BVS     %FT05
Kevin Bracey's avatar
Kevin Bracey committed
269

270 271 272 273
        ; copy filters
        MOV     r0, #2_001
        ADR     r1, copyfilter_token
        BL      writeheadings
Kevin Bracey's avatar
Kevin Bracey committed
274 275 276
        BVS     %FT05

        LDR     r3, copy_filters
277 278
        B       %FT58
51
Kevin Bracey's avatar
Kevin Bracey committed
279 280 281 282 283
        LDR     r0, [r3, #f_name]
        MOV     r1, r5
        BL      writefield
        SWIVC   XOS_NewLine
        BVS     %FT05
284
53
Kevin Bracey's avatar
Kevin Bracey committed
285
        LDR     r3, [r3, #next_ptr]
286
58
Kevin Bracey's avatar
Kevin Bracey committed
287
        CMP     r3, #0
288
        BNE     %BT51
Neil Turton's avatar
Neil Turton committed
289 290
05
        ADD     sp, sp, r4
291
        Pull    "r7-r9,PC"
Neil Turton's avatar
Neil Turton committed
292 293 294 295 296 297 298 299

lookuptostack
; In:   r1->token
;       r4=current size of data on stack
; Out:  r1,r2 corrupted
;       r3=length of text found
;       r4=new size of data on stack
;       sp->text
300
        MOV     r8, lr                  ; Don't use stack in here (BLs are OK though)
Neil Turton's avatar
Neil Turton committed
301 302
        MOV     r2, #0
        BL      MsgTrans_Lookup
303
        MOVVS   pc, r8
Neil Turton's avatar
Neil Turton committed
304 305 306 307 308 309 310 311 312 313 314 315 316 317

        ADD     r1, r3, #4              ; Word align length (allow for terminator).
        BIC     r1, r1, #3
        SUB     sp, sp, r1              ; Allocate space on stack.
        ADD     r4, r4, r1

        MOV     r1, sp
06
        LDRB    r0, [r2], #1
        CMP     r0, #" "
        STRCSB  r0, [r1], #1
        BCS     %BT06
        MOV     r0, #0
        STRB    r0, [r1]
318
        MOV     pc, r8
Neil Turton's avatar
Neil Turton committed
319

320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387
writetaskname ROUT
; Write a task name (from ID) or "All"
; In:   r0 = the Task ID
;       r6 = width of heading column
; Out:  r0 corrupted
        Push    "r1-r2,lr"
        CMP     r0, #0
        LDREQ   r0, all_text
        SWINE   XTaskManager_TaskNameFromHandle
        MOVVC   r1, r6
        BLVC    writefield
        Pull    "r1-r2,pc"

writeheadings ROUT
; Write the introductory text and column headings for a filter
; In:   r0 = bitfield asking for b0 = filter heading
;                                b1 = task heading
;                                b2 = mask heading
;       r1 -> token for introductory text
;       r5-r7 = width of heading columns
        Push    "r0-r4,lr"
        MOV     r4, r0                  ; Flags for later
        MOV     r2, #0
        BL      MsgTrans_Lookup
        MOVVC   r0, r2
        MOVVC   r1, r3
        SWIVC   XOS_WriteN
        SWIVC   XOS_NewLine
        Pull    "r0-r4,pc",VS

        TST     r4,#1                   ; Want filter heading
        LDRNE   r0, filter_text
        MOVNE   r1, r5
        BLNE    writefield
        Pull    "r0-r4,pc",VS

        TST     r4,#2                   ; Want task heading
        LDRNE   r0, task_text
        MOVNE   r1, r6
        BLNE    writefield
        Pull    "r0-r4,pc",VS

        TST     r4,#4                   ; Want mask heading
        LDRNE   r0, mask_text
        MOVNE   r1, r6
        BLNE    writefield
        SWIVC   XOS_NewLine             ; Newline regardless
        Pull    "r0-r4,pc",VS

        TST     r4,#1                   ; Want filter heading
        LDRNE   r0, filter_text
        MOVNE   r1, r5
        BLNE    writefield_dashed
        Pull    "r0-r4,pc",VS

        TST     r4,#2                   ; Want task heading
        LDRNE   r0, task_text
        MOVNE   r1, r6
        BLNE    writefield_dashed
        Pull    "r0-r4,pc",VS

        TST     r4,#4                   ; Want mask heading
        LDRNE   r0, mask_text
        MOVNE   r1, r6
        BLNE    writefield_dashed
        SWIVC   XOS_NewLine             ; Newline regardless
        Pull    "r0-r4,pc"
        
Neil Turton's avatar
Neil Turton committed
388
writefield
389
; Write control-terminated string, padded with spaces to field width
Neil Turton's avatar
Neil Turton committed
390 391 392 393 394
; In:   r0 = text to print
;       r1 = field width
; Out:  r0,r2 corrupted
        Push    "lr"
        MOV     r2, r0
Robert Sprowson's avatar
Robert Sprowson committed
395
        BL      Write32
Neil Turton's avatar
Neil Turton committed
396 397 398 399 400
        Pull    "pc",VS
        SUB     r0, r0, r2
        SUB     r0, r1, r0
07
        SWI     XOS_WriteI+" "
401 402 403
        Pull    "pc",VS
        SUBS    r0, r0, #1
        BGE     %BT07
Stewart Brodie's avatar
Stewart Brodie committed
404
        Pull    "pc"
405 406 407 408 409 410 411 412

Write32
; Output a control character terminated string to fit in a given field width
; In:   R0 -> Ctrl-terminated string
;       R1 =  field width
        Push    "R1,R2,LR"
;
        SUB     R1,R1,#min_gap
Robert Sprowson's avatar
Robert Sprowson committed
413 414 415 416 417 418 419 420 421
        MOV     R2,R0
01      LDRB    R0,[R2],#1
        CMP     R0,#32
        SUBHSS  R1,R1,#1
        MOVLO   R0,R2
        Pull    "R1,R2,PC",LO
        SWI     XOS_WriteC
        BVC     %BT01
        Pull    "R1,R2,PC"
422 423 424 425 426 427 428 429 430 431 432

writefield_dashed
; Write dashes for the length of the given control-terminated string, and pad with spaces to field width
; In:   r0 = text string
;       r1 = field width
; Out:  r0,r2 corrupted
        Push    "lr"
        MOV     r2, r0
01
        LDRB    lr, [r0], #1
        CMP     lr, #32
Robert Sprowson's avatar
Robert Sprowson committed
433
        SWIHS   XOS_WriteI+"-"
434 435 436 437 438 439 440
        Pull    "pc",VS
        BHS     %BT01
        SUB     r0, r0, r2
        SUB     r0, r1, r0
07
        SWI     XOS_WriteI+" "
        Pull    "pc",VS
Neil Turton's avatar
Neil Turton committed
441 442
        SUBS    r0, r0, #1
        BGE     %BT07
Stewart Brodie's avatar
Stewart Brodie committed
443
        Pull    "pc"
Neil Turton's avatar
Neil Turton committed
444 445 446

; ----------------------------------------------------------------------------------------------------------------------
Helptable
447 448
      [ international_help
        Command "Filters", 0, 0, International_Help
Neil Turton's avatar
Neil Turton committed
449
        DCB     0
450 451
      |
        Command "Filters", 0, 0, 0
Neil Turton's avatar
Neil Turton committed
452
        DCB     0
453 454 455
      ]
; ----------------------------------------------------------------------------------------------------------------------
      [ international_help
Neil Turton's avatar
Neil Turton committed
456 457
Filters_Help    DCB     "HFLMFLT", 0
Filters_Syntax  DCB     "SFLMFLT", 0
458 459 460 461 462 463
      |
Filters_Help
        DCB     "*Filters displays all Wimp filters currently active.", 0
Filters_Syntax
        DCB     "Syntax: *Filters", 0
      ]
Neil Turton's avatar
Neil Turton committed
464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481
        ALIGN
; ----------------------------------------------------------------------------------------------------------------------
;       Module initialisation point
Init
        Push    "r0-r3,LR"

        LDR     r2, [r12]
        CMP     r2, #0                  ; clears V
        BNE     %FT01

        MOV     r0, #ModHandReason_Claim
        MOV     r3, #max_running_work
        SWI     XOS_Module
        ADDVS   sp,sp,#4
        Pull    "r1-r3,PC",VS

        STR     r2, [r12]
01
Robert Sprowson's avatar
Robert Sprowson committed
482
        MOV     wp, r2
Neil Turton's avatar
Neil Turton committed
483 484 485 486 487 488

; Clear list pointers

        MOV     r0, #0
        STR     r0, pre_filters
        STR     r0, post_filters
Kevin Bracey's avatar
Kevin Bracey committed
489
        STR     r0, rect_filters
Robert Sprowson's avatar
Robert Sprowson committed
490 491 492
        STR     r0, copy_filters
        STR     r0, post_rect_filters
        STR     r0, post_icon_filters
Neil Turton's avatar
Neil Turton committed
493
        STR     r0, flags               ; Clear flags.
Stewart Brodie's avatar
Stewart Brodie committed
494 495 496
        [ No26bitCode
        STR     r0, fake_postrect
        ]
Neil Turton's avatar
Neil Turton committed
497

Kevin Bracey's avatar
Kevin Bracey committed
498
; If we're on a Wimp earlier than 3.86, then we need to fake post-rectangle filters
Robert Sprowson's avatar
Robert Sprowson committed
499 500 501
        MOV     r0, #7
        SWI     Wimp_ReadSysInfo
        SUB     r0, r0, #256
Stewart Brodie's avatar
Stewart Brodie committed
502
        [ :LNOT: No26bitCode
Robert Sprowson's avatar
Robert Sprowson committed
503 504 505 506
        CMP     r0, #386-256
        MOVLT   r1, #1
        MOVGE   r1, #0
        STR     r1, fake_postrect
Stewart Brodie's avatar
Stewart Brodie committed
507
        ]
508
; If we're on a Wimp earlier than 3.99, then we cannot rely on getting handles from r10
Robert Sprowson's avatar
Robert Sprowson committed
509 510 511 512
        CMP     r0, #399-256
        MOVLT   r1, #0
        MOVGE   r1, #1
        STR     r1, get_handle_from_r10
Kevin Bracey's avatar
Kevin Bracey committed
513

Robert Sprowson's avatar
Robert Sprowson committed
514 515 516
        [ standalone
        BL      declareresourcefsfiles
        ]
Kevin Bracey's avatar
Kevin Bracey committed
517

Neil Turton's avatar
Neil Turton committed
518
        ADR     R0,servicecallback
Robert Sprowson's avatar
Robert Sprowson committed
519
        MOV     R1,wp                   ; workspace pointer
Neil Turton's avatar
Neil Turton committed
520 521 522
        SWI     XOS_AddCallBack         ;   install the call back to broadcast we are here message
        MOVVC   R0,#-1
        STRVC   R0,callbackpending      ; and then setup a suitable flag to indicate we have a callback pending
523 524
        Pull    "r0-r3,LR"              ; No errors
        RETURNVC                        ; clear V
Neil Turton's avatar
Neil Turton committed
525 526 527 528 529 530 531

;;-----------------------------------------------------------------------------
;; When the CallBack is granted we then broadcast a service call so that
;;   all Filters can be registered that are required.
;;-----------------------------------------------------------------------------

servicecallback
532
        EntryS  "R0-R1"
Neil Turton's avatar
Neil Turton committed
533 534 535 536

        MOV     R1,#0                   ; the callback has been granted, so flag as no longer pending
        STR     R1,callbackpending

537
        LDR     R0,=Module_Version
Neil Turton's avatar
Neil Turton committed
538 539 540
        MOV     R1,#Service_FilterManagerInstalled
        SWI     XOS_ServiceCall         ; broadcast the service

541
        EXITS
Neil Turton's avatar
Neil Turton committed
542 543 544 545
        LTORG

; ----------------------------------------------------------------------------------------------------------------------
;       Module service entry point
546
ServiceTable
547
        ASSERT  Service_WimpCloseDown < Service_ResourceFSStarting 
548
        ASSERT  Service_ResourceFSStarting < Service_WimpRegisterFilters
549 550
        DCD     0                               ; flags word
        DCD     Service2 - Module_BaseAddr
551
        DCD     Service_WimpCloseDown
552
      [ standalone
553 554 555
        DCD     Service_ResourceFSStarting
      ]
        DCD     Service_WimpRegisterFilters
556 557 558
        DCD     0                               ; terminator

        DCD     ServiceTable - Module_BaseAddr
Neil Turton's avatar
Neil Turton committed
559
Service
560
        MOV     R0, R0                          ; flag service table to aware kernels
Neil Turton's avatar
Neil Turton committed
561
        TEQ     R1,#Service_WimpRegisterFilters
562
        TEQNE   R1,#Service_WimpCloseDown
Kevin Bracey's avatar
Kevin Bracey committed
563
      [ standalone
Robert Sprowson's avatar
Robert Sprowson committed
564
        TEQNE   R1,#Service_ResourceFSStarting
Kevin Bracey's avatar
Kevin Bracey committed
565
      ]
Stewart Brodie's avatar
Stewart Brodie committed
566
        MOVNE   PC,LR
567
Service2
Kevin Bracey's avatar
Kevin Bracey committed
568 569 570 571
      [ standalone
        TEQ     R1,#Service_ResourceFSStarting
        BEQ     serviceresourcefsstarting
      ]
Neil Turton's avatar
Neil Turton committed
572

Robert Sprowson's avatar
Robert Sprowson committed
573
        LDR     wp, [R12]
Neil Turton's avatar
Neil Turton committed
574 575 576
        CMP     R12, #0
        MOVEQ   PC, LR                  ; Exit if no workspace

577 578 579 580
        TEQ     R1,#Service_WimpCloseDown
        BEQ     servicewimpclosedown
        ; else must be Service_WimpRegisterFilters

Neil Turton's avatar
Neil Turton committed
581 582 583 584 585 586 587 588 589 590
;-------------------------------------
; Register our filters with the Wimp
; In:
;  R12 -> workspace
;
; Out:
;   VC if filters registered

RegisterFilters
        Push    "r0-r2,LR"
Kevin Bracey's avatar
Kevin Bracey committed
591

Stewart Brodie's avatar
Stewart Brodie committed
592
        [ :LNOT: No26bitCode
Robert Sprowson's avatar
Robert Sprowson committed
593 594 595 596
        LDR     LR,fake_postrect
        TEQ     LR,#0
        MOVNE   R0,#0
        STRNE   R0,int_get_rectangle_reentry_addr
Stewart Brodie's avatar
Stewart Brodie committed
597
        ]
Kevin Bracey's avatar
Kevin Bracey committed
598

Neil Turton's avatar
Neil Turton committed
599 600 601 602 603 604 605 606 607 608 609 610
        LDR     LR,pre_filters
        CMP     LR,#0                   ; Any pre-filters?
        MOVNE   R0,#0                   ; Pre_filter
        ADRNEL  R1,pre_filter_handler
        MOVNE   R2,R12

        Debug   register,"Register pre-filter",R0,R1,R2,LR

        SWINE   XWimp_RegisterFilter    ; Yes then register

        DebugE  register,"Cant register pre-filter "

Robert Sprowson's avatar
Robert Sprowson committed
611
        ADDVS   r13,r13,#4
Kevin Bracey's avatar
Kevin Bracey committed
612 613 614 615
        Pull    "r1-r2,PC",VS

        LDR     LR,rect_filters
        CMP     LR,#0                   ; Any rect-filters?
Robert Sprowson's avatar
Robert Sprowson committed
616
        BNE     %FT01
Kevin Bracey's avatar
Kevin Bracey committed
617

Robert Sprowson's avatar
Robert Sprowson committed
618 619 620 621 622
        LDR     LR,post_rect_filters
        CMP     LR,#0                   ; how about post-rect-filters?
        BEQ     %FT02
        LDR     LR,fake_postrect
        CMP     LR,#0
Kevin Bracey's avatar
Kevin Bracey committed
623 624 625 626 627 628 629 630 631 632 633

01      MOVNE   R0,#3                   ; rect_filter
        ADRNEL  R1,rect_filter_handler
        MOVNE   R2,R12

        Debug   register,"Register rect-filter",R0,R1,R2,LR

        SWINE   XWimp_RegisterFilter    ; Yes then register

        DebugE  register,"Cant register rect-filter "

Robert Sprowson's avatar
Robert Sprowson committed
634
        ADDVS   r13,r13,#4
Kevin Bracey's avatar
Kevin Bracey committed
635 636 637 638 639 640 641 642 643 644 645 646 647 648
        Pull    "r1-r2,PC",VS

02      LDR     LR,copy_filters
        CMP     LR,#0                   ; Any copy-filters?
        MOVNE   R0,#2                   ; copy_filter
        ADRNEL  R1,copy_filter_handler
        MOVNE   R2,R12

        Debug   register,"Register copy-filter",R0,R1,R2,LR

        SWINE   XWimp_RegisterFilter    ; Yes then register

        DebugE  register,"Cant register copy-filter "

Robert Sprowson's avatar
Robert Sprowson committed
649
        ADDVS   r13,r13,#4
Kevin Bracey's avatar
Kevin Bracey committed
650
        Pull    "r1-r2,PC",VS
Neil Turton's avatar
Neil Turton committed
651 652 653

        LDR     LR,post_filters
        CMP     LR,#0                   ; Any post-filters?
Kevin Bracey's avatar
Kevin Bracey committed
654
        MOVNE   R0,#WimpFilter_PostPoll
Neil Turton's avatar
Neil Turton committed
655 656 657 658 659 660 661 662 663
        ADRNEL  R1,post_filter_handler
        MOVNE   R2,R12

        Debug   register,"Register post-filter",R0,R1,R2,LR

        SWINE   XWimp_RegisterFilter    ; Yes then register

        DebugE  register,"Cant register post-filter "

Robert Sprowson's avatar
Robert Sprowson committed
664
        ADDVS   r13,r13,#4
Kevin Bracey's avatar
Kevin Bracey committed
665 666 667 668 669 670 671 672 673 674 675 676 677 678
        Pull    "r1-r2,PC",VS

        LDR     LR,post_icon_filters
        CMP     LR,#0                   ; Any post-icon-filters?
        MOVNE   R0,#WimpFilter_PostIconGetRectangle
        ADRNEL  R1,post_icon_filter_handler
        MOVNE   R2,R12

        Debug   register,"Register post-icon-filter",R0,R1,R2,LR

        SWINE   XWimp_RegisterFilter    ; Yes then register

        DebugE  register,"Cant register post-icon-filter "

Robert Sprowson's avatar
Robert Sprowson committed
679
        ADDVS   r13,r13,#4
Kevin Bracey's avatar
Kevin Bracey committed
680 681
        Pull    "r1-r2,PC",VS

Robert Sprowson's avatar
Robert Sprowson committed
682 683 684
        LDR     LR,fake_postrect
        TEQ     LR,#0
        Pull    "r0-r2,PC",NE
Kevin Bracey's avatar
Kevin Bracey committed
685

Robert Sprowson's avatar
Robert Sprowson committed
686 687 688 689 690
        LDR     LR,post_rect_filters
        CMP     LR,#0                   ; Any post-rect-filters?
        MOVNE   R0,#4                   ; post_rect_filter
        ADRNEL  R1,post_rect_filter_handler
        MOVNE   R2,R12
Kevin Bracey's avatar
Kevin Bracey committed
691 692 693

        Debug   register,"Register post-rect-filter",R0,R1,R2,LR

Robert Sprowson's avatar
Robert Sprowson committed
694 695
        SWINE   XWimp_RegisterFilter
        STRVS   r0,[r13]
Kevin Bracey's avatar
Kevin Bracey committed
696

Robert Sprowson's avatar
Robert Sprowson committed
697
        DebugE  register,"Can't register post-rect-filter "
Kevin Bracey's avatar
Kevin Bracey committed
698

699 700
        Pull    "r0-r2,LR"
        RETURNVC
Neil Turton's avatar
Neil Turton committed
701

Kevin Bracey's avatar
Kevin Bracey committed
702 703 704 705 706 707
      [ standalone
; ResourceFS has been reloaded - redeclare resource files
; In    R2 -> address to call
;       R3 -> workspace for ResourceFS module

serviceresourcefsstarting
708
        Push    "r0,LR"
Kevin Bracey's avatar
Kevin Bracey committed
709 710 711
        ADRL    R0,resourcefsfiles
        MOV     LR,PC                   ; LR -> return address
        MOV     PC,R2                   ; R2 -> address to call
712 713 714
        NOP
        Pull    "r0,LR"
        RETURN
Kevin Bracey's avatar
Kevin Bracey committed
715 716
      ]

717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741
; Wimp says a task has quit
; In    R0 = 0 if closing, +ve if new task starting killed another
;       R2 = task handle
servicewimpclosedown ROUT
        CMP     r0,#0
        RETURN  NE
        Push    "r1-r2,LR"
        MOV     r2,r2,LSL #16
        MOV     r2,r2,LSR #16

        ; Mark dead any pre filters matching that Task ID
        LDR     r1,pre_filters
        BL      flag_quit_list
        LDR     r1,rect_filters
        BL      flag_quit_list
        LDR     r1,post_filters
        BL      flag_quit_list
        LDR     r1,post_rect_filters
        BL      flag_quit_list
        LDR     r1,post_icon_filters
        BL      flag_quit_list
        ;       r1, copy_filters          Copy filters don't use a Task ID
        Pull    "r1-r2,LR"
        RETURN

Neil Turton's avatar
Neil Turton committed
742 743 744 745
; ----------------------------------------------------------------------------------------------------------------------
;       RMKill'ing the module  -  Release filter handlers. Release linked lists of filters.
Die
;
Robert Sprowson's avatar
Robert Sprowson committed
746
        LDR     wp, [r12]
Neil Turton's avatar
Neil Turton committed
747
        CMP     r12, #0
748 749
        RETURN  EQ

Robert Sprowson's avatar
Robert Sprowson committed
750
        Push    "r7-r11,LR"
Neil Turton's avatar
Neil Turton committed
751 752 753

        ADR     r2, pre_filters
        BL      free_list               ; Free list of pre filters
Kevin Bracey's avatar
Kevin Bracey committed
754 755
        ADR     r2, rect_filters
        BL      free_list               ; Free list of rect filters
Neil Turton's avatar
Neil Turton committed
756 757
        ADR     r2, post_filters
        BL      free_list               ; Free list of post filters
Kevin Bracey's avatar
Kevin Bracey committed
758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773
        ADR     r2, post_rect_filters
        BL      free_list               ; Free list of post rect filters
        ADR     r2, post_icon_filters
        BL      free_list               ; Free list of post icon filters
        ADR     r2, copy_filters
        BL      free_list               ; Free list of copy filters

        MOV     R0,#WimpFilter_PrePoll
        MOV     R1,#0
        MOV     R2,#0
        SWI     XWimp_RegisterFilter    ; Ignore errors.

        MOV     R0,#WimpFilter_GetRectangle
        MOV     R1,#0
        MOV     R2,#0
        SWI     XWimp_RegisterFilter    ; Ignore errors.
Neil Turton's avatar
Neil Turton committed
774

Kevin Bracey's avatar
Kevin Bracey committed
775
        MOV     R0,#WimpFilter_PostPoll
Neil Turton's avatar
Neil Turton committed
776 777 778 779
        MOV     R1,#0
        MOV     R2,#0
        SWI     XWimp_RegisterFilter    ; Ignore errors.

Kevin Bracey's avatar
Kevin Bracey committed
780 781 782 783 784 785 786 787 788 789 790
        MOV     R0,#WimpFilter_BlockCopy
        MOV     R1,#0
        MOV     R2,#0
        SWI     XWimp_RegisterFilter    ; Ignore errors.

        MOV     R0,#WimpFilter_PostGetRectangle
        MOV     R1,#0
        MOV     R2,#0
        SWI     XWimp_RegisterFilter    ; Ignore errors.

        MOV     R0,#WimpFilter_PostIconGetRectangle
Neil Turton's avatar
Neil Turton committed
791 792 793 794 795 796 797
        MOV     R1,#0
        MOV     R2,#0
        SWI     XWimp_RegisterFilter    ; Ignore errors.

        LDR     R0,callbackpending
        CMP     R0,#0                   ; do we have a callback pending? (clears V)
        ADRNE   R0,servicecallback      ;   yes, so remove it before its granted
Robert Sprowson's avatar
Robert Sprowson committed
798
        MOVNE   R1,wp                   ;   as we are going to die
Neil Turton's avatar
Neil Turton committed
799 800 801 802 803 804 805 806
        SWINE   XOS_RemoveCallBack

        MOV     R0,#0
        STR     R0,callbackpending      ; and then remove it

        MOV     R1,#Service_FilterManagerDying
        SWI     XOS_ServiceCall         ; broadcast that the module is dying so you are no longer installed

Kevin Bracey's avatar
Kevin Bracey committed
807 808 809 810 811
      [ standalone
        ADRL    R0,resourcefsfiles
        SWI     XResourceFS_DeregisterFiles ; ignore errors
      ]

Neil Turton's avatar
Neil Turton committed
812 813
        BL      MsgTrans_CloseFile      ; Make sure Messages file is closed.

Robert Sprowson's avatar
Robert Sprowson committed
814
        Pull    "R7-R11,LR"
815
        RETURNVC                        ; clear V - don't refuse to die
Neil Turton's avatar
Neil Turton committed
816

Kevin Bracey's avatar
Kevin Bracey committed
817 818
; ----------------------------------------------------------------------------------------------------------------------

Robert Sprowson's avatar
Robert Sprowson committed
819
        LNK     SWIs.s