com.sun.rtsjx
Class PhysicalMemoryRequest

java.lang.Object
  extended by com.sun.rtsjx.PhysicalMemoryRequest

public final class PhysicalMemoryRequest
extends java.lang.Object

Class representing the constraints specificed by a memory type.

It includes the parameters for a mmap UNIX call, which is the default mapping mechanism. set_mapper() can be used to override this default.

It the type Object is null, a malloc/free schem is used. If not PhysicalMemoryRequest provides a powerfull mechanism to add constraints with both security and consistency checks.

At initialization time, the filters corresponding to the type Object are memorized. The addContraints method of core filters is called. For the other filters, the flags and attributes are incorporated into the mmap arguments.

Constraints are validated at creation time and before each mapping to ensure security and consistency. It starts with the mapper dependent checkMapperConstraints, which may modify the mmap value. For the next steps, the arguments are frozen to protect from unsecure changes during the validation and mapping phase. The checkConstraints method of each core filter is called. For the non core filters, checkConstraints() ensures that prot and flags include the bits specified by getVMFlags() and getVMAttribytes().

mmap arguments are unfrozen after the mapping to allow future changes. If the freeze() method is called, they remain frozen forever. If not, they are unfrozen after the mapping to allow changes before a remapping.


Nested Class Summary
static class PhysicalMemoryRequest.RegisteredList
          Class used internaly to associate names to filters.
 
Field Summary
 long initial_pbase
          Physical base address specified before parsing the types.
static int MAP_ALIGN
          Access to POSIX constants.
static int MAP_ANON
          Access to POSIX constants.
static int MAP_FIXED
          Access to POSIX constants.
static int MAP_NORESERVE
          Access to POSIX constants.
static int MAP_PRIVATE
          Access to POSIX constants.
static int MAP_SHARED
          Access to POSIX constants.
static int PROT_EXEC
          Access to POSIX constants.
static int PROT_NONE
          Access to POSIX constants.
static int PROT_READ
          Access to POSIX constants.
static int PROT_WRITE
          Access to POSIX constants.
 long requested_address
          Requested address.
 long requested_size
          Size specified before parsing the types.
 
Method Summary
 void close_fildes()
           
 void freeze()
          Reject all future changes.
 RawMemoryAccessImpl get_accessor()
          Read the accessor.
 long get_addr()
          Read the addr parameter of the Unix mmap call.
 java.lang.String get_device()
           
 int get_fildes()
          Read the fildes parameter of the Unix mmap call.
 int get_flags()
          Read the flags parameter of the Unix mmap call.
 boolean get_inlinable()
          Read the inlinable status.
 long get_len()
          Read the len parameter of the Unix mmap call.
 long get_mapped_address()
          Read the mapped address.
 PhysicalMemoryMapper get_mapper()
          Read the registered mapper.
 int get_off()
          Read the off parameter of the Unix mmap call.
 int get_prot()
          Read the prot parameter of the Unix mmap call.
 boolean get_readable()
          Read the readable status.
 boolean get_writable()
          Read the writable status.
static PhysicalMemoryRequest.RegisteredList getList()
           
 boolean is_mapping()
          Return true if executing map() or unmap().
 long map()
          Map the request.
static PhysicalMemoryRequest parseType(java.lang.Object type, long base, long size, boolean mappit)
           
static PhysicalMemoryRequest parseType(java.lang.Object type, long base, long size, boolean mappit, java.lang.String device)
          Create the PhysicalMemoryRequest corresponding to the type parameter of the physical memory related methods.
static void registerFilter(java.lang.Object name, javax.realtime.PhysicalMemoryTypeFilter filter)
          Register a memory type filter with the physical memory manager.
static void removeFilter(java.lang.Object name)
          Remove the identified filter from the set of registered filters.
 void set_accessor(RawMemoryAccessImpl accessor)
          Set the addr parameter of the Unix mmap call.
 void set_addr(long addr)
          Set the addr parameter of the Unix mmap call.
 void set_device(java.lang.String device)
           
 void set_flags(int flags)
          Set the flags parameter of the Unix mmap call.
 void set_inlinable(boolean inlinable)
          Set the inlinable status.
 void set_len(long len)
          Set the len parameter of the Unix mmap call.
 void set_mapper(PhysicalMemoryMapper mapper)
          Set the mapper.
 void set_off(int off)
          Set the off parameter of the Unix mmap call.
 void set_prot(int prot)
          Set the prot parameter of the Unix mmap call.
 void set_readable(boolean readable)
          Set the readable status.
 void set_unmappable(boolean inlinable)
          Set the unmappable status.
 void set_writable(boolean writable)
          Set the writable status.
 void unmap()
          Undo a mapping.
 boolean unmappable()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROT_READ

public static final int PROT_READ
Access to POSIX constants.


PROT_WRITE

public static final int PROT_WRITE
Access to POSIX constants.


PROT_EXEC

public static final int PROT_EXEC
Access to POSIX constants.


PROT_NONE

public static final int PROT_NONE
Access to POSIX constants.


MAP_ALIGN

public static final int MAP_ALIGN
Access to POSIX constants.


MAP_ANON

public static final int MAP_ANON
Access to POSIX constants.


MAP_FIXED

public static final int MAP_FIXED
Access to POSIX constants.


MAP_NORESERVE

public static final int MAP_NORESERVE
Access to POSIX constants.


MAP_PRIVATE

public static final int MAP_PRIVATE
Access to POSIX constants.


MAP_SHARED

public static final int MAP_SHARED
Access to POSIX constants.


initial_pbase

public final long initial_pbase
Physical base address specified before parsing the types.

It is used for the remappings.


requested_size

public long requested_size
Size specified before parsing the types.


requested_address

public long requested_address
Requested address.

Method Detail

map

public long map()
         throws javax.realtime.OffsetOutOfBoundsException,
                javax.realtime.MemoryTypeConflictException,
                javax.realtime.SizeOutOfBoundsException,
                java.lang.OutOfMemoryError
Map the request.

If the type parsing has not registered a mapper, the default unix mmap call is performed. Else, the map method of this mapper is caller.

Throws:
javax.realtime.OffsetOutOfBoundsException - Thrown if the address is invalid.
javax.realtime.MemoryTypeConflictException - Thrown if the specified base does not point to memory that matches the request type, or if type specifies incompatible memory attributes.
java.lang.OutOfMemoryError - Thrown if the requested type of memory exists, but there is not enough of it free to satisfy the request.
javax.realtime.SizeOutOfBoundsException

unmap

public void unmap()
Undo a mapping.


is_mapping

public boolean is_mapping()
Return true if executing map() or unmap().

Returns:
true if executing map() or unmap().

get_inlinable

public boolean get_inlinable()
Read the inlinable status.


get_readable

public boolean get_readable()
Read the readable status.


get_writable

public boolean get_writable()
Read the writable status.


get_accessor

public RawMemoryAccessImpl get_accessor()
Read the accessor.


get_addr

public long get_addr()
Read the addr parameter of the Unix mmap call.


get_len

public long get_len()
Read the len parameter of the Unix mmap call.


get_prot

public int get_prot()
Read the prot parameter of the Unix mmap call.


get_flags

public int get_flags()
Read the flags parameter of the Unix mmap call.


get_fildes

public int get_fildes()
Read the fildes parameter of the Unix mmap call.


get_device

public java.lang.String get_device()

get_off

public int get_off()
Read the off parameter of the Unix mmap call.


get_mapper

public PhysicalMemoryMapper get_mapper()
Read the registered mapper.


get_mapped_address

public long get_mapped_address()
Read the mapped address.


freeze

public void freeze()
            throws javax.realtime.MemoryTypeConflictException
Reject all future changes.

It may be called while processing a type to forbid other changes before the validation phase.

Throws:
javax.realtime.MemoryTypeConflictException - mmap arguments conflict

set_mapper

public void set_mapper(PhysicalMemoryMapper mapper)
Set the mapper.

Throws:
javax.realtime.MemoryTypeConflictException - if another mapper has been registered.

set_accessor

public void set_accessor(RawMemoryAccessImpl accessor)
Set the addr parameter of the Unix mmap call.


set_addr

public void set_addr(long addr)
Set the addr parameter of the Unix mmap call.


set_inlinable

public void set_inlinable(boolean inlinable)
Set the inlinable status.

inlinable is true by default and must be cleared by filters that do not support direct pointer access.


set_unmappable

public void set_unmappable(boolean inlinable)
Set the unmappable status.

unmappable is true by default and must be cleared by filters that do not support unmapping memory.


unmappable

public boolean unmappable()

set_readable

public void set_readable(boolean readable)
Set the readable status.

It is true by default and should be set to false only:


set_writable

public void set_writable(boolean writable)
Set the writable status.

It is true by default and should be set to false only:


set_len

public void set_len(long len)
Set the len parameter of the Unix mmap call.


set_prot

public void set_prot(int prot)
Set the prot parameter of the Unix mmap call.

This call also changes the readable and writable status.


set_flags

public void set_flags(int flags)
Set the flags parameter of the Unix mmap call.


close_fildes

public void close_fildes()

set_device

public void set_device(java.lang.String device)

set_off

public void set_off(int off)
Set the off parameter of the Unix mmap call.


parseType

public static PhysicalMemoryRequest parseType(java.lang.Object type,
                                              long base,
                                              long size,
                                              boolean mappit)
                                       throws java.lang.SecurityException,
                                              javax.realtime.OffsetOutOfBoundsException,
                                              javax.realtime.SizeOutOfBoundsException,
                                              javax.realtime.UnsupportedPhysicalMemoryException,
                                              javax.realtime.MemoryTypeConflictException,
                                              java.lang.OutOfMemoryError
Throws:
java.lang.SecurityException
javax.realtime.OffsetOutOfBoundsException
javax.realtime.SizeOutOfBoundsException
javax.realtime.UnsupportedPhysicalMemoryException
javax.realtime.MemoryTypeConflictException
java.lang.OutOfMemoryError

parseType

public static PhysicalMemoryRequest parseType(java.lang.Object type,
                                              long base,
                                              long size,
                                              boolean mappit,
                                              java.lang.String device)
                                       throws java.lang.SecurityException,
                                              javax.realtime.OffsetOutOfBoundsException,
                                              javax.realtime.SizeOutOfBoundsException,
                                              javax.realtime.UnsupportedPhysicalMemoryException,
                                              javax.realtime.MemoryTypeConflictException,
                                              java.lang.OutOfMemoryError
Create the PhysicalMemoryRequest corresponding to the type parameter of the physical memory related methods.

A static method is used instead of a direct call to a constructor to allow future implementations to extend this class and override methods when processing the types.

Parameters:
type - An Object representing the type of memory required. Used to define the base address and control the mapping.
base - Requested base, or -1 if not specified.
size - The size of the area in bytes.
mappit - true if map is done before exiting
Throws:
java.lang.SecurityException - Thrown if application doesn't have permissions to access physical memory, the specified range of addresses, or the given type of memory.
javax.realtime.OffsetOutOfBoundsException - Thrown if the address is invalid.
javax.realtime.SizeOutOfBoundsException - Thrown if the size is negative or extends into an invalid range of memory.
javax.realtime.UnsupportedPhysicalMemoryException - Thrown if the underlying hardware does not support the given type, or if no matching PhysicalMemoryTypeFilter has been registered with the PhysicalMemoryManager.
javax.realtime.MemoryTypeConflictException - Thrown if the specified base does not point to memory that matches the request type, or if type specifies incompatible memory attributes.
java.lang.OutOfMemoryError - Thrown if the requested type of memory exists, but there is not enough of it free to satisfy the request.

getList

public static PhysicalMemoryRequest.RegisteredList getList()

registerFilter

public static final void registerFilter(java.lang.Object name,
                                        javax.realtime.PhysicalMemoryTypeFilter filter)
                                 throws javax.realtime.DuplicateFilterException
Register a memory type filter with the physical memory manager.

Parameters:
name - The type of memory handled by this filter.
filter - The filter object.
Throws:
javax.realtime.DuplicateFilterException - A filter for this type of memory already exists.

removeFilter

public static final void removeFilter(java.lang.Object name)
Remove the identified filter from the set of registered filters.

Parameters:
name - The identifying object for this memory attribute.