home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Datafile PD-CD 5
/
DATAFILE_PDCD5.iso
/
utilities
/
a
/
appsswi
/
!ReadMe
next >
Wrap
Text File
|
1995-10-22
|
15KB
|
283 lines
WimpSWIVe 0.05 (30 Oct 1995)
==================================
NewerLook needs to trap Wimp_ SWIs in order to provide its new error
windows. The only official way to trap SWIs is to trap the SWI hardware
vector, but even this is not recommended. It takes much code to implement
properly in *all* circumstances (about 30K of source code in Desktop Hacker),
and can slow the machine down, quite considerably when there are multiple
claimants.
It is, however, possible to trap Wimp_ SWIs by providing another module
with the same SWI chunk and names. This method is much quicker and easier,
but it is - as I’ll happily admit - rather dodgy. One of the problems is
that only one module can do this at a time. So if NewerLook had a module
that used this method, it wouldn’t work properly when another program tried
to do the same thing. (And you know some program will.)
Thus, I have separated the trapping code from the action code (which resides
in another module), and released this module separately. It can manage SWI
claims and releases dynamically, a bit like vectors. Actually, quite a lot
like vectors. You can use it in your own programs if you like. Here’s how.
Because WimpSWIVe uses the Wimp’s SWI chunk, it cannot provide its own
SWIs. Instead, it communicates using a Wimp SWI, namely Wimp_RegisterFilter.
Here is the WimpSWIVe specification for Wimp_RegisterFilter.
| Wimp_RegisterFilter
| (SWI &400F5)
|
| Used by the Filter Manager to register or deregister a filter
| OR used to register SWI claims and releases with WimpSWIVe
|
On entry: | R0 = reason code:
| &49575357 (“WSWI”) for WimpSWIVe operation (see below)
| anything else for filter operation (see RISC OS 3
| Programmers’ Reference Manual, page 3-224)
| R1 = SWI word:
| bits 0-5 : offset in SWI chunk of SWI to claim/release
| bit 6 : ignore bits 0-5 and claim all Wimp_ SWIs
| bits 7-29: undefined, leave unset
| bit 30 : high priority if set, else low priority
| bit 31 : claim if set, else release
| R2 = value to be passed in R12 on entry to code
| R3 = address of SWI pre-trapping code, or 0 if none needed
| R4 = address of SWI post-trapping code, or 0 if none needed
|
On exit: | Registers preserved
|
Interrupts: | Interrupts may be enabled
| Fast interrupts may be enabled
|
Processor: | Processor is in SVC mode
|
Reentrancy: | SWI is not re-entrant
|
Use: | In WimpSWIVe usage, this SWI is used to claim or release SWIs.
| The pre-trapping code specified is called before the SWI is
| called, and the post-trapping code afterwards.
|
| High-priority pre-code is called before low priority pre-code.
| (And high-priority post-code is called after low priority
| post-code.) This is important because one piece of pre-code
| could intercept a SWI call before another bit got a look in.
| You should use high-priority code for monitoring and register-
| altering code. If your pre-code is at all likely to intercept
| a SWI, you must use low-priority code. In effect, low-priority
| code is ‘closer’ to the real SWI.
|
| Pre-trapping code conditions:
|
| On entry: R0-R8 = registers passed to SWI
| R9 = offset into chunk of SWI called
| R12 = value specified when RegisterFilter called
| R13 = full, descending stack
| R14 = return address
| On exit: R0-R8 = may be altered to change effect of SWI
| R9 = preserved, or -1 to intercept SWI
|
| Pre-trapping code is entered in SVC mode, with interrupts
| disabled. If R9=-1 on exit, the SWI is not called. Instead,
| any outstanding post-code is called, and the caller is returned
| to with the supplied R0-R8 and PSR flags. An error may be
| signified by pointing R0 to an error block and setting the V
| flag on return as normal, when intercepting. (See footnote 1.)
|
| If more than one client has claimed a SWI, it is the earliest
| claimant’s pre-trapping code that is called last - new
| claimants take priority (though high-priority always beats low-
| priority, of course). If interception occurs, any post-trapping
| code for claims where the pre-trapping code (if any) has
| already been executed are also executed. In effect, you are
| guaranteed that you will get a post-trap event if you have had
| a pre-trap. (See footnote 2.)
|
|
| Post-trapping code conditions:
|
| On entry: R0-R8 = registers passed back from SWI
| R9 = offset into chunk of SWI called
| R12 = value specified when RegisterFilter called
| R13 = full, descending stack
| R14 = return address
| On exit: R0-R8 = may be altered to change perceived results
| PSR flags may be altered to change perceived results
| (for example to flag an error).
|
| Post-trapping code is entered in SVC mode, with interrupts
| disabled.
|
| If more than one client has claimed a SWI, it is the earliest
| claimant’s post-trapping code that is called first, subject
| to priority. (See footnote 2.)
|
| Remember that your post-trapping code may well be entered in an
| error condition. So check whether the V flag is set on entry,
| and return if it is (if you return with the S flag (MovS Pc,R14
| or LdmFd R13!,{...,Pc}^, the flags are unaffected). Never
| change the PSR flags by accident.
|
|
| Unlike OS_Claim, this SWI will not remove previous instances of
| claims with the same values. The release routine also only
| removes one instance of the values at a time.
|
| Claiming the Wimp_RegisterFilter SWI only traps the normal
| filter-based use of the SWI. Under no circumstances should you
| call Wimp_RegisterFilter with WimpSWIVe usage in your trapping
| code. If you really must claim or release a SWI when some other
| SWI is executed, use a CallBack to do it. (See the RISC OS 3
| Programmers’ Reference Manual, page 1-319.)
|
| Don’t post-trap Wimp_Poll(Idle) or Wimp_StartTask: it’s a bad
| idea. WimpSWIVe deals with it adequately, but there are all
| sorts of simply horrid implications. Trapping Wimp_Poll is
| easy anyway, using the old filter system.
|
| And finally, don’t use the ‘claim all SWIs’ flag unless you
| really want all the SWIs. Don’t use it for trapping a number
| of different SWIs, use many separate claims: the speed
| difference will be negligable, and you needn’t worry about
| Wimp_Poll. The ‘claim all SWIs’ flag is unlikely to be widely
| useful - a Wimp SWI logging program seems to be the only
| possible user.
|
Errors: | Bad value passed to WIMP in R0
| if WimpSWIVe is not loaded, the attempt to use this SWI in
| the WimpSWIVe manner will cause this error
| Bad WimpSWIVe release
| releasing a SWI you had not