OS Memory

Introduction and Overview

OS_Memory calls have been updated. The following lists the reason codes which are allocated :

ReasonMeaning
0General block operations. See PRM 5a-62
1-5Reserved for internal use. See PRM 5a-64
6Read size of physical memory arrangement table. See PRM 5a-65 and this document
7Read physical memory arrangement table. See PRM 5a-66 and this document
8Read memory amounts. See PRM 5a-68 and this document
9Read controller presence and logical base address. See PRM 5a-69 and this document
10Lock free pool. See this document
11Map PCI memory. See this document
12Recommend page. See this document
13-23Reserved for future expansion
24Check memory access. See this document
25Read controller presence and physical base address. See this document

SWI Calls

OS_Memory 6OS_Memory_ReadTableSizeSWI &68
Read size of physical memory arrangement table
R0=6 (reason code), all flag bits are currently reserved and must be 0
R1=Table size
R2=Page size
Interrupts are undefined
Fast interrupts are undefined
Processor is in undefined mode
Not defined

This SWI is now deprecated.

OS_Memory 7OS_Memory_ReadTableSWI &68
Read physical memory arrangement table
R0=7 (reason code), all flag bits are currently reserved and must be 0
R1=Pointer to table to fill in
None
Interrupts are undefined
Fast interrupts are undefined
Processor is in undefined mode
Not defined

This SWI is now deprecated and may not return reliable information for a given OS version.

OS_Memory 8OS_Memory_ReadAmountsSWI &68
Read amount of memory
R0=8 + flags:
Bit(s)Meaning
8-11Type of memory:
ValueMeaning
1DRAM
2VRAM
3ROM
4I/O
5Softload ROM
6+Reserved
12-31Reserved, must be 0
None
Interrupts are undefined
Fast interrupts are undefined
Processor is in undefined mode
Not defined

This SWI is used to read the amount of various types of memory available within the machine. On modern versions of RISC OS, the amount of VRAM will be returned as 0, as VRAM is now reserved to the video driver, rather than the Kernel. The new type 5 for softload RAM indicates the amount of memory allocated from DRAM (and excluded from the value returned for type 1).

OS_Memory 9OS_Memory_ReadControllerLogicalSWI &68
Read controller presence and base logical address
R0=9 (reason code), all flag bits are currently reserved and must be 0
R1=Controller ID:
Bit(s)Meaning
0-7Controller sequence number
8-31Controller type:
ValueMeaning
0EASI card access speed control
1EASI space
2VIDC1
3VIDC20
4+Reserved
R0=Preserved
R1=Controller logical address
Interrupts are undefined
Fast interrupts are undefined
Processor is in undefined mode
Not defined

This SWI is used to read the base address of a controller in logical address space. Under modern versions of the OS the correct way to obtain access to a controller is to create a dynamic area with the controller address mapped in to it. The Kernel will not map parts of hardware memory in future versions. This SWI is thus less useful in modern OS versions. Its behaviour has been changed slightly to correct an oversight in the original design. The original definition stated that 0 could be returned for an absent controller, in addition to an error being reported for an invalid controller. The implementation now returns an error for all controllers which do not exist, and 0 will not be returned.

See PRM 5a-69 for the original definition.

OS_Memory AOS_Memory_LockFreePoolSWI &68
Lock free pool
R0=10 + flags:
Bit(s)Meaning
8Call made by Wimp
9-31Reserved, must be 0
None
Interrupts are undefined
Fast interrupts are undefined
Processor is in undefined mode
Not defined

This SWI was allocated in RISC OS 4 for locking the free pool in order to implement Wimp_ClaimFreeMemory. The Wimp_ClaimFreeMemory call should not be used and this call is no longer used.

OS_Memory BOS_Memory_MapPCISWI &68
Map PCI memory
R0=11 + flags:
Bit(s)Meaning
8Set to read information, clear to map PCI space
9-31Reserved, must be 0
R1 - R3=Dependent on flags
None
Interrupts are undefined
Fast interrupts are undefined
Processor is in undefined mode
Not defined

This SWI was allocated in RISC OS 4 for mapping PCI memory within the Phoebe hardware. PCI memory allocation should now be performed by clients through the PCI manager module. The PCI manager module will use physical memory areas to provide drivers with memory mappings. This call is no longer used.

OS_Memory COS_Memory_RecommendPageSWI &68
Recommend page
R0=12 + flags:
Bit(s)Meaning
8Set if pages should be in DMA-able memory
9-31Reserved, must be 0
R1=Size of contiguous region of physical memory required in bytes
R2=Log base 2 of required alignment of base of region within physical memory, between 12 (4K) and 30 (2G)
R3=Page number of first page which fulfils the requirements specified
Interrupts are undefined
Fast interrupts are undefined
Processor is in undefined mode
Not defined

This SWI is used to recommend pages of physical RAM which are unallocated and may be used for a new dynamic area. It is expected that they will be used to create a dynamic area, or to extend an existing area. An error will be returned if no pages match the required criteria. Prior to Kernel 8.77, bit 8 was not supported. This SWI call is available from RISC OS 4 onward.

OS_Memory 18OS_Memory_CheckAccessSWI &68
Check memory access
R0=24 (reason code), all flag bits are currently reserved and must be 0
R1=Low address
R2=High address
R1=Access flags:
Bit(s)Meaning
0Range is completely readable in user mode
1Range is completely writable in user mode
2Range is completely readable in privileged modes
3Range is completely writable in privileged modes
4Range is partially readable in user mode
5Range is partially writable in user mode
6Range is partially readable in privileged modes
7Range is partially writable in privileged modes
8Range is completely physically mapped
9Range is completely abortable (aborts handled by code)
10-11Reserved for future expansion
12Range is partially physically mapped
13Range is partially abortable (aborts handled by code)
14-15Reserved for future expansion
16-31Reserved for future expansion
Interrupts are undefined
Fast interrupts are undefined
Processor is in undefined mode
Not defined

This SWI is used to determine the accessibility of a range of memory. It is similar to the SWI OS_ValidateAddress call in that it uses the Dynamic Area details to determine the availability of memory areas. The region from 'low address' to 'high address'-1 will be considered.

The flags returned indicate the access which is available for the range. Because the range may span (multiple) page boundaries the access for the range may vary across its length. Consequently, the two extents of accessibility are returned. Bits are separated into pairs of 4 bits. The lower 4 bits indicate the lowest level of accessibility for the region specified. The upper 4 bits indicate the highest level of accessibility for the region specified. If the bit sets are identical then the accessibility of the region does not change.

OS_Memory 19OS_Memory_ReadControllerPhysicalSWI &68
Read controller presence and base physical address
R0=25 (reason code), all flag bits are currently reserved and must be 0
R1=Controller ID:
Bit(s)Meaning
0-7Controller sequence number
8-31Controller type:
ValueMeaning
0EASI card access speed control
1EASI space
2VIDC1
3VIDC20
4Reserved for Pace OS variants
5Expansion ROMs
6-31Reserved for Pace OS variants
32Primary ROM
33IOMD
34FDC37C665 or similar
35+Reserved for future hardware
R0=Preserved
R1=Controller physical address
Interrupts are undefined
Fast interrupts are undefined
Processor is in undefined mode
Not defined

This call checks for the presence of a given controller and returns its physical address. This allows hardware drivers to provide support for specific controllers which may exist at different physical locations on other hardware. This call is similar to OS_Memory 9.