RISCOS.com

www.riscos.com Technical Support:
Programmer's Reference Manual

 

The Filter Manager


Introduction and Overview

The Filter Manager provides facilities for you to register filters to be used when a specified task calls Wimp_Poll, or when Wimp_Poll is about to return to that task. These are known - respectively - as pre-filters and post-filters:

  • With a pre-filter, you may alter the event mask the task passes to Wimp_Poll
  • With a post-filter, you may modify the reason code and data block returned by Wimp_Poll to provide a new event to the task, or to prevent an event form being returned to the task.

Filters need not be applied to a specific task; you can also apply filters to all tasks.

Each filter is a routine that has well-defined entry and exit conditions; it is your responsibility to write the routine.

Service Calls


Service_FilterManagerInstalled
(Service Call &87)

Filter Manager starting up

On entry

R1 = &87 (reason code)

On exit

All registers preserved

Use

This service call is issued when the Filter Manager starts up. You may then register new filters using Filter_RegisterPreFilter and Filter_RegisterPostFilter.


Service_FilterManagerDying
(Service Call &88)

Filter Manager dying

On entry

R1 = &88 (reason code)

On exit

All registers preserved

Use

This service call is issued as a broadcast to inform filters that they have been deregistered and that the Filter Manager is about to die.

SWI calls


Filter_RegisterPreFilter
(SWI &42640)

Adds a new pre-filter to the list of pre-filters

On entry

R0 = pointer to filter name (null terminated)
R1 = pointer to filter routine
R2 = value to be passed in R12 when filter is called
R3 = task handle to which to apply filter (or 0 for all tasks)

On exit

All registers preserved

Interrupts

Interrupt status is undefined
Fast interrupts are enabled

Processor mode

Processor is in SVC mode

Re-entrancy

Not defined

Use

This call registers a pre-filter routine (pointed to by R1), which will be called whenever the specified task calls Wimp_Poll.

The entry and exit conditions of the filter routine are:

On entry

R0 = event mask, as passed to Wimp_Poll
R1 = pointer to event block, as passed to Wimp_Poll
R2 = task handle of task that called Wimp_Poll
R12 = value of R2 on entry to this SWI (ie Filter_RegisterPreFilter)

On exit

It may clear bits in R0 to provide a new event mask

It must preserve all registers other than R0.

The routine should exit using the instruction:

MOVS pc, r14

Related SWIs

Filter_RegisterPostFilter, Filter_DeRegisterPreFilter

Related vectors

None


Filter_RegisterPostFilter
(SWI &42641)

Adds a new post-filter to the list of post-filters

On entry

R0 = pointer to filter name (null terminated)
R1 = pointer to filter routine
R2 = value to be passed in R12 when filter is called
R3 = task handle to which to apply filter (or 0 for all tasks)
R4 = event mask (1 bit masks the event out as for Wimp_Poll)

On exit

All registers preserved

Interrupts

Interrupt status is undefined
Fast interrupts are enabled

Processor mode

Processor is in SVC mode

Re-entrancy

Not defined

Use

This call registers a post-filter routine (pointed to by R1), which will be called whenever the Wimp is about to return from Wimp_Poll to the specified task.

The entry and exit conditions of the filter routine are:

On entry

R0 = event reason code, as returned from Wimp Poll
R1 = pointer to event block, as returned from Wimp Poll
R2 = task handle of task that is being returned to
R12 = value of R2 on entry to this SWI (ie Filter_RegisterPostFilter)

Task is paged in, so you can access its memory

On exit
The routine may modify the reason code in R0 and the contents of the buffer pointed to by R1 to provide a new event. By setting R0 to -1 on exit it may claim the event, and prevent it from being passed to the task.

It must preserve all registers other than R0.

The routine should exit using the instruction:

MOVS pc, r14

Note: Under RISC OS 3, if a filter routine sets R0 to -1 to claim an event and prevent it being passed to its task, then that event is not passed on to any further post filters. From RISC OS 3.5 onwards, claiming an event does not prevent other post filters from being called, but does still prevent the event being passed to the task.

Related SWIs

Filter_RegisterPreFilter, Filter_DeRegisterPostFilter

Related vectors

None


Filter_DeRegisterPreFilter
(SWI &42642)

Removes a pre-filter from the list of pre-filters

On Entry

R0 = pointer to filter name (null terminated)
R1 = pointer to filter routine
R2 = value to be passed in R12 when filter is called
R3 = task handle to which to apply filter (or 0 for all tasks)

On exit

All registers preserved

Interrupts

Interrupt status is undefined
Fast interrupts are enabled

Processor mode

Processor is in SVC mode

Re-entrancy

Not defined

Use

This call removes a pre-filter from the list of pre-filters. All values on entry must be the same as those used to originally register the filter (ie those that were passed to Filter_RegisterPreFilter).

Related SWIs

Filter_RegisterPreFilter

Related vectors

None


Filter_DeRegisterPostFilter
(SWI &42643)

Removes a post-filter from the list of post-filters

On entry

R0 = pointer to filter name (null terminated)
R1 = pointer to filter routine
R2 = value to be passed in R12 when filter is called
R3 = task handle to which to apply filter (or 0 for all tasks)
R4 = event mask (1 bit masks the event out as for Wimp_Poll)

On exit

All registers preserved

Interrupts

Interrupt status is undefined
Fast interrupts are enabled

Processor mode

Processor is in SVC mode

Re-entrancy

Not defined

Use

This call removes a post-filter from the list of post-filters. All values on entry must be the same as those used to originally register the filter (ie those that were passed to Filter_RegisterPostFilter).

Related SWIs

Filter_RegisterPostFilter

Related vectors

None

* Commands


*Filters

Lists all currently active pre- and post-Wimp_Poll filters

Syntax

*Filters

Parameters

None

Use

*Filters lists all currently active pre- and post-Wimp_Poll filters.

Example

*Filters
Filters called on entry to Wimp_Poll:
Filter              Task                    
------              ----                    
Llama               All tasks
Filters called on exit from Wimp_Poll:
Filter              Task                    Mask    
------              ----                    ----    
Llama               All tasks               00000000

Related commands

None

Related SWIs

Filter_RegisterPreFilter, Filter_RegisterPostFilter

Related vectors

None

This edition Copyright © 3QD Developments Ltd 2015
Last Edit: Tue,03 Nov 2015