|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.sun.rtsjx.PhysicalMemoryRequest
public final class PhysicalMemoryRequest
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 | |
---|---|
boolean |
canRemap()
Returns true if a remap() can be attempted. |
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 |
---|
public static final int PROT_READ
public static final int PROT_WRITE
public static final int PROT_EXEC
public static final int PROT_NONE
public static final int MAP_ALIGN
public static final int MAP_ANON
public static final int MAP_FIXED
public static final int MAP_NORESERVE
public static final int MAP_PRIVATE
public static final int MAP_SHARED
public final long initial_pbase
It is used for the remappings.
public long requested_size
public long requested_address
Method Detail |
---|
public long map() throws javax.realtime.OffsetOutOfBoundsException, javax.realtime.MemoryTypeConflictException, javax.realtime.SizeOutOfBoundsException, java.lang.OutOfMemoryError
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.
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
public void unmap()
public boolean is_mapping()
public boolean canRemap()
public boolean get_inlinable()
public boolean get_readable()
public boolean get_writable()
public RawMemoryAccessImpl get_accessor()
public long get_addr()
public long get_len()
public int get_prot()
public int get_flags()
public int get_fildes()
public java.lang.String get_device()
public int get_off()
public PhysicalMemoryMapper get_mapper()
public long get_mapped_address()
public void freeze() throws javax.realtime.MemoryTypeConflictException
It may be called while processing a type to forbid other changes before the validation phase.
javax.realtime.MemoryTypeConflictException
- mmap
arguments conflictpublic void set_mapper(PhysicalMemoryMapper mapper)
javax.realtime.MemoryTypeConflictException
- if
another mapper has been registered.public void set_accessor(RawMemoryAccessImpl accessor)
public void set_addr(long addr)
public void set_inlinable(boolean inlinable)
inlinable is true by default and must be cleared by filters that do not support direct pointer access.
public void set_unmappable(boolean inlinable)
unmappable is true by default and must be cleared by filters that do not support unmapping memory.
public boolean unmappable()
public void set_readable(boolean readable)
It is true by default and should be set to false only:
public void set_writable(boolean writable)
It is true by default and should be set to false only:
public void set_len(long len)
public void set_prot(int prot)
This call also changes the readable and writable status.
public void set_flags(int flags)
public void close_fildes()
public void set_device(java.lang.String device)
public void set_off(int off)
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
java.lang.SecurityException
javax.realtime.OffsetOutOfBoundsException
javax.realtime.SizeOutOfBoundsException
javax.realtime.UnsupportedPhysicalMemoryException
javax.realtime.MemoryTypeConflictException
java.lang.OutOfMemoryError
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
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.
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
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.public static PhysicalMemoryRequest.RegisteredList getList()
public static final void registerFilter(java.lang.Object name, javax.realtime.PhysicalMemoryTypeFilter filter) throws javax.realtime.DuplicateFilterException
name
- The type of memory handled by this filter.filter
- The filter object.
javax.realtime.DuplicateFilterException
- A filter for this type of memory
already exists.public static final void removeFilter(java.lang.Object name)
name
- The identifying object for this memory attribute.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |