Latest News
!System updates

Development tools
C/C++ Tools

Writing 32-bit code
32-bit introduction
32-bit overview
32-bit technical
Memory issues
Developer tools
Paul Skirrow's Guide (PDF)
Download area

32-bit APIs
API changes
CallASWI
FileCore

RISC OS 5
Overview
BBC BASIC
CDFS driver
OS_ClaimDeviceVector behaviour
CDFS
Draw clipping
GraphicsV
HAL
Internet
UTF8 & Japanese support
International IME support
MIMEMap
Module PostInit/Final
PCI Manager
PDumper
Podules
Resource allocation
SCSI
Service Calls
UCS fonts
USB
WIMP API Changes
WIMP Flags

IYONIX pc
DDR memory
Help system
Keyboard layout
Miscellaneous
PCI slots

Opportunities

Iyonix Ltd
IYONIX home page
Contact details

   

Service Calls

In RISC OS 3 every service call was passed to every module (until claimed) and this resulted in poor performance when a lot of service calls were being issued to a large number of modules.

RISC OS 4 and RISC OS 5 provide a mechanism to speed up service call handling which should be used by all modules that have a service call entry point. The mechanism is backwards compatible, allowing modules to be written to work with any version of RISC OS.

The word at module offset &C gives the address of the service call handler and the handler normally runs some fast rejection code to exit quickly if the service number is unrecognized.

In RISC OS 4 and later, the first instruction of the service call handler may be set to 'MOV R0,R0' to indicate that a service call table is present and the pointer to the table immediately precedes the 'MOV R0,R0' instruction.

The table comprises the address of a second service call handler function (for use by RISC OS 4 and later systems) followed by a zero terminated list of service numbers that are recognized by the module.

The second service call handler function still needs to decode the service number (unless the module only provides one service call), but it does not need to execute the fast rejection code as it is known that the service call is relevant to the module at that point.

For example, in a module:

         Address   Data
         00000000  DCD &00000000       ; Start offset
         0000000C  DCD &00005EA4       ; Initialisation offset
         00000008  DCD &00006094       ; Finalisation offset
         0000000C  DCD &00006104       ; Service call handler offset
         
         000060E0  DCD &00000000       ; Start of service call table
         000060E4  DCD &60F8           ; Address to jump to when issuing one of the following service calls
         000060E8  DCD &27             ; List of service calls that module is interested in
         000060EC  DCD &8A
         000060F0  DCD &10802
         000060F4  DCD 0               ; End of table
         
         000060F8  STMFD    SP!,{LR}   ; RISC OS 4 service call entry (fast rejection code is not needed)
         000060FC  B        &6124
                 
         00006100  DCD      &60E0      ; Offset to service call table (from start of module)
          
         ; Service call handler:
          
         00006104  MOV      R0,R0      ; Service call handler with magic word to tell RISC OS 4/RISC OS 5
                                       ;  this module has a service call table
          
         ; Fast rejection code:
         
         00006108  STMFD    SP!,{LR}   ; RISC OS 2/RISC OS 3 service call fast rejection code
         0000610C  TEQ      R1,#&27    ; Check for service calls that are wanted
         00006110  TEQNE    R1,#&8A    ;  (&27, &8A, &10802)
         00006114  LDRNE    LR,&62D0  
         00006118  TEQNE    R1,R14
         0000611C  LDMNEFD  SP!,{PC}   ; Not for me, so exit
           
         ; Second entry point:
          
         00006120  ...                 ; Service call is for me, so decode it...

Using Service Call Tables with CMHG

CMHG 5.10 and later allow the service call to be specified as follows:
         service-call-handler:   handler_function  service1, service2...

Handler function is the name of the handler function and this is followed by a list of service calls that the module is interested in.

Note that CMHG can now use pre-processor directive when the -p command line option is specified and this can make the text more meaningful as it allows for symbolic names to be used in place of the numeric codes. See the Docs.ChangeLogs.cmhg file for more details.

© 2006 IYONIX Ltd 32-bit RISC OS