RISC OS Open
A fast and easily customised operating system for ARM devices
ROOL
Home | News | Software | Bugs | Bounties | Forum | Documents | Photos | Contact us
Account

VFPSupport

VFPSupport API – for VFPSupport 0.02

VFPSupport_CheckContext

(SWI &58EC0)
Entry
R0 Flags
b0 = User mode flag (0=user mode access not required, 1=user mode access required)
b1 = Application space flag (0=context not in application space, 1=context in application space)
b30-31 ignores (for CreateContext compatability)
Other bits reserved, sbz
R1 Number of doubleword registers required (1-32)
Exit
R0 Required size of context save area
- Other registers preserved

Checks if it’s possible to create a context with the indicated settings, and how much memory is required for the context save area if the application is to manage memory allocation itself. The size of the context save area (for a particular combination of R0 and R1) will not change at runtime, but is subject to change across different machines or OS versions.

Returns an error if the required features are unavailable.

VFPSupport_CreateContext

(SWI &58EC1)
Entry
R0 Flags
b0 = User mode flag (0=user mode access not required, 1=user mode access required)
b1 = Application space flag (0=context not in application space, 1=context in application space)
b30 = Activate lazily flag (0=don’t activate lazily, 1=activate lazily)
b31 = Activate flag (0=leave context inactive, 1=activate now)
Other bits reserved, sbz
R1 Number of doubleword registers required (1-32)
R2 Pointer to word-aligned context save area of the size indicated by VFPSupport_CheckContext, or 0 if VFPSupport is to allocate memory itself
R3 FPSCR value to initialise context with
Exit
R0 Context pointer
R1 Previously active context (iff R0 b30 or b31 == 1 on entry, else preserved)
- Other registers preserved

Creates and potentially activates a context.

If R2 is supplied, the parameters in R0 and R1 must be identical to those passed to VFPSupport_CheckContext when determining the context size (with the exception of the high-bit flags which CheckContext is documented as ignoring). Use bit 1 of R0 to indicate whether the context is in application space or not (or whether it’s in some other area of memory that will be paged in/out by the Wimp). If the context isn’t in a paged area that’s managed by the Wimp, then it must be in a non-paged area. If R2 is supplied then the context pointer returned in R0 will be identical to the value of R2 given on entry.

If R2 isn’t supplied then VFPSupport will allocate the required amount of memory for you. In this case, bit 1 of R1 must be clear.

Bits 30 and 31 of R0 control whether the context should be immediately activated or left inactive. If bit 30 is set then bit 31 is ignored.

Returns an error if the required features are unavailable.

Note that if R2 is supplied then fewer error checks than normal may be performed, under the assumption that the caller correctly responded to any errors returned by CheckContext.

VFPSupport_DestroyContext

(SWI &58EC2)
Entry
R0 Context ID
R1 Context to activate if R0 was the active context
Exit
R0 Context that’s now active (whether R0 was active or not)
- Other registers preserved

Destroys a context, potentially activating the indicated context if the context being destroyed was the active one.

Returns error if context not found.

If an error is returned, the active context will not be modified.

VFPSupport_ChangeContext

(SWI &58EC3)
Entry
R0 Context to activate
R1 Flags
b0 = Lazy activation (0=activate now, 1=use lazy activation)
b1 = Application space changing flag (0=no change, 1=changing)
other bits reserved, sbz
Exit
R0 Previously active context
- Other registers preserved

Activates the specified context, potentially using lazy activation.

If bit 1 of R1 is set then it indicates that application space is about to be changed. If this bit is set, and any active context is flagged as being in application space, then a nonlazy context switch will occur, regardless of the setting of R1 bit 0. This allows the Wimp to safely use lazy context switching when deactivating contexts during task switches.

Returns error if context not found.

If an error is returned, the active context will not be modified.

VFPSupport_ExamineContext

(SWI &58EC4)
Entry
R0 Context
R1 Flags
b0 = Serialise context
Other bits reserved, sbz
Exit
R0 Flags
b0 = User mode flag (0=user mode access not required, 1=user mode access required)
b1 = Application space flag (0=context isn’t in application space, 1=context is in application space)
b29 = Context is awaiting lazy activation (1=yes, 0=no)
b30 = Context status registers are active (1=active, 0=saved)
b31 = Memory allocation method (0=user allocated, 1=VFPSupport allocated)
R1 Number of doubleword registers (may be greater than number requested upon context creation)
R2 Register status. bit ‘n’ is 1 if doubleword register ‘n’ is active, 0 if saved.
R3 Pointer to dump format descriptor block
R4 Context size
- Other registers preserved

The format descriptor block is a list of words describing the format of the register dump. The list is terminated by the word -1. Each word is split in two halves: bits 0-15 give the type/format of the data, and bits 16-31 give the byte offset of the data, relative to the context pointer (R0 on entry). Not all entries will be present for all contexts.

Format halfword values:

Value Meaning Data length
0 FPSCR register 4 bytes
1 FPEXC register 4 bytes
2 FPINST register 4 bytes
3 FPINST2 register 4 bytes
4 FLDMX/FSTMX format word (as produced by FSTMX for R1 registers, VFPv1 only) 4 bytes
5 Register dump (from D0 upwards, as saved by FSTMX if VFPv1 or FSTMD if VFPv2D+, or FSTMS if VFPv2xD+) 8*R1 bytes

Returns an error if context not found.

VFPSupport_FastAPI

(SWI &58EC5)
Entry
- -
Exit
R0 Workspace pointer to pass in R12
R1 CheckContext function pointer
R2 CreateContext function pointer
R3 DestroyContext function pointer
R4 ChangeContext function pointer
- Other registers preserved

FastAPI can be used as a fast way of context switching from privileged modes. Calling convention is as per the individual SWIs, with errors being reported in an identical manner (e.g. V set and error block ptr in R0)

VFPSupport_ActiveContext

(SWI &58EC6)
Entry
- -
Exit
R0 Currently active context pointer (or pointer to context pending lazy activation)

VFPSupport_Version

(SWI &58EC7)
Entry
- -
Exit
R0 Module version number * 100

VFPSupport_Features

(SWI &58EC8)
Entry
R0 Reason code:
0 = Return FPSID, MVFR0, MVFR1 values
- Other reigsters dependent upon reason code
Exit
Dependent upon reason code

VFPSupport_Features 0

Entry
R0 0
Exit
R0 FPSID value
R1 MVFR0 value
R2 MVFR1 value
- Other registers preserved

Returns the values of the FPSID, MVFR0, & MVFR1 registers. Note: VFPv1 has no MVFR0/MVFR1 registers, so on such a system the contents of R1 and R2 should be ignored.

Other notes

For all SWIs, a context pointer of 0 represents a null context (i.e. VFP/NEON access disabled).

As long as the context memory wasn’t allocated by VFPSupport, the context can be freely moved, copied, or deleted by user programs as long as VFPSupport_ExamineContext reports that the context is inactive (bits 28 & 29 of R0 clear, and R2 == 0). However be wary of moving a non-application space context into application space and then activating it. Saving/restoring contexts to/from disc is possible, but is not advised if the context is to be loaded on a different machine or with a different version of VFPSupport, as the internal context structure is subject to change between machine types & module versions.

In order to safely deactivate a context in order to allow it to be manually manipulated, all that is required is to perform a non-lazy context switch to another context, or to the null contet.

Note that the version of VFPSupport_ExamineContext used in VFPSupport 0.02 and above is backwards-incompatible with the version used in version 0.01.

Revised on July 7, 2011 02:08:20 by Jeffrey Lee (213) (91.84.11.161)
Edit | Back in time (5 revisions) | See changes | History | Views: Print | Source | Linked from: Cortex-A8 port status

Search the Wiki

Commercial use

For commercial enquiries, please contact the owners of RISC OS, Castle Technology Ltd.

ROOL Store

The official C/C++ Development kit and more here.

Donate! Why?

Help ROOL make things happen – please consider donating!

Navigation

  • Home Page
  • All Pages
  • Recently Revised
  • Authors
  • Feeds
Site design © RISC OS Open Limited 2011 except where indicated
The RISC OS Open Instiki theme is based on Insitki's default layout

Valid XHTML 1.0  |  Valid CSS

Instiki 0.19.1(MML+)
This site runs on Rails

Hosted by Arachsys