home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Datafile PD-CD 5
/
DATAFILE_PDCD5.iso
/
utilities
/
c
/
callaswi
/
Read
< prev
Wrap
Text File
|
1996-10-25
|
6KB
|
170 lines
OS_CallASWI
-----------
Unofficial version, written by Darren Salt
Implements the SA support SWIs from RISC OS 3.7. Suitable for RISC OS 3.1,
and probably 3.5 and 3.6 as well.
DO NOT USE WITH ANY SA-AWARE VERSION OF RISC OS.
The X forms of the SWIs should be used; wherever possible, avoid using their
names. It is not a good idea to assume other people have this module!
See Acorn's SA support documentation for more details of the following SWIs.
(The text below is adapted from this.)
OS_PlatformFeatures (SWI &6D)
-----------------------------
Reason code 0: read code features
On entry
R0 = 0 (reason code); all flags are reserved, so bits 16-31 must be clear
On exit
R0 = bit mask of features:
Bits Meaning
0 Must tell OS when code areas change (by calling
OS_SynchroniseCodeAreas)
1 Enabling, then immediately disabling interrupts will _not_
give interrupts a chance to occur
2 Must be in 32 bit mode to read hardware vectors
3 Storing PC to memory (eg with STR or STM) stores PC+8
rather than PC+12
4 Data aborts occur with 'full early' timing (ie. as defined
by ARM architecture 4)
If bit 1 of R0 set then
R1 -> routine to call (with BL) between IRQ enable & disable.
Use
This call determines features of the host processor's instruction set.
Since this implementation is not for use with StrongARM, it returns with
all bits clear.
If you get an 'SWI not known' error, this is equivalent to R0 with bits 0
to 4 clear.
OS_SynchroniseCodeAreas (SWI &6E)
---------------------------------
Inform the OS that code has been altered
On entry
R0 = flags
bit 0 clear Entire address space to be synchronised.
bit 0 set Address range to be synchronised.
bits 1-31 Reserved
If R0 bit 0 is set then:
R1 = low address of range (word aligned)
R2 = high address (word aligned, _inclusive_)
On exit
R0-R2 preserved
Use
This new SWI informs the OS that code has been newly generated or
modified in memory, before any attempt is made to execute the code.
The 'full' implementation of this SWI has potentially large performance
penalties. This version, not being intended for StrongARM use, just
returns immediately.
OS_CallASWI (SWI &6F)
---------------------
Call a run-time determined SWI
On entry
R0-R9 as required for target SWI
R10 = target SWI number
On exit
R0-R9 as defined by target SWI
R10 preserved
Interrupt status, processor mode, re-entrancy
As defined by target SWI
Use
This new SWI allows a target SWI number to be determined at run time, and
passed in a register. This removes the need for a common idiom of dynamic
code, in language library SWI veneers for example. In an APCS-R library,
OS_CallASWIR12 may be more appropriate (see below).
Note that OS_CallASWI is merely an alias for calling the target SWI. It
has no entry/exit conditions of its own, except for the special use of
R10. To call a target SWI with X bit set, us the X form of the SWI number
in R10; there is no distinction between OS_CallASWI and XOS_CallASWI.
You cannot call OS_CallASWI or OS_CallASWIR12 via OS_CallASWI, since
there is no defined final target SWI in this case. (This implementation
generates an error if you attempt to do so.)
You cannot usefully call OS_BreakPt or OS_CallAVector using OS_CallASWI,
as OS_CallASWI will corrupt the processor flags before entering the
target SWI.
For future compatibility, you should always use this SWI in preference to
any local construction for calling a SWI by number.
Note that this SWI calling mechanism is almost certainly faster than any
other alternative implementation, including the original _kernel_swi and
_swix code contained in older versions of the SharedCLibrary. The new
(RO3.70) SharedCLibrary now simply uses OS_CallASWIR12 for _kernel_swi
and _swix.
OS_CallASWI cannot be called from BASIC as BASIC only passes registers
R0-R7 via its SYS instruction. It would not be useful anyway.
OS_CallASWIR12 (SWI &71)
------------------------
Call a run-time determined SWI
On entry
R0-R9 as required for target SWI
R12 = target SWI number
On exit
R0-R9 as defined by target SWI
R12 preserved
Interrupt status, processor mode, re-entrancy
As defined by target SWI
Use
This call is identical to OS_CallASWI, except that it uses R12 to specify
the target SWI. This may be more convenient in some environments. In
particular under APCS-R, R10 is the stack limit pointer, which must be
preserved at all times; if a SWI called using OS_CallASWI were to abort
or generate an error the run-time library would usually examine R10 and
decide that it had no stack to handle the abort or error. Therefore
APCS-R libraries must use OS_CallASWIR12 (R12 being a scratch register
under APCS-R).
THE CALLASWI MODULE
===================
The CallASWI module provides support under RISC OS 3.1, 3.5 and 3.6 for
the following SWIs:
OS_CallASWI
OS_CallASWIR12
OS_PlatformFeatures
OS_SynchroniseCodeAreas
This will enable application programmers and library writers to use the new
calls freely without any worries about backwards compatibility. There is no
performance penalty for the use of these SWIs via the CallASWI module.
Unlike Acorn's implementation, this version *does* allow you to use the SWI
names.