javax.realtime
Class RawMemoryAccess

java.lang.Object
  extended byjavax.realtime.RawMemoryAccess
Direct Known Subclasses:
RawMemoryFloatAccess

public class RawMemoryAccess
extends Object

A class permitting access to specific memory offsets within the process address space.

jRate programs should refer to RealtimeSystem's BYTE_ORDER field to determine if they are running on big-endian or little-endian systems.

Raw memory areas cannot contain references to Java objects.

Since:
0.3.8
Author:
Morgan Deters

Constructor Summary
RawMemoryAccess(Object type, long size)
          Constructs a raw memory accessor associated to a memory area of the given memory type and size.
RawMemoryAccess(Object type, long base, long size)
          Constructs a raw memory accessor associated to a memory area of the given memory type and size, based at the given offset.
 
Method Summary
 byte getByte(long offset)
          Get the byte at the given offset.
 void getBytes(long offset, byte[] bytes, int low, int number)
          Get a consecutive sequence of bytes at the given offset.
 int getInt(long offset)
          Get the int at the given offset.
 void getInts(long offset, int[] ints, int low, int number)
          Get a consecutive sequence of ints at the given offset.
 long getLong(long offset)
          Get the long at the given offset.
 void getLongs(long offset, long[] longs, int low, int number)
          Get a consecutive sequence of longs at the given offset.
 long getMappedAddress()
          Returns the virtual memory location at which this physical memory area is mapped.
 short getShort(long offset)
          Get the short at the given offset.
 void getShorts(long offset, short[] shorts, int low, int number)
          Get a consecutive sequence of shorts at the given offset.
 long map()
          Map the physical memory range into virtual memory.
 long map(long base)
          Map the physical memory range into virtual memory.
 long map(long base, long size)
          Map the physical memory range into virtual memory.
 void setByte(long offset, byte value)
          Set the byte at the given offset.
 void setBytes(long offset, byte[] bytes, int low, int number)
          Set a consecutive sequence of bytes at the given offset.
 void setInt(long offset, int value)
          Set the int at the given offset.
 void setInts(long offset, int[] ints, int low, int number)
          Set a consecutive sequence of ints at the given offset.
 void setLong(long offset, long value)
          Set the long at the given offset.
 void setLongs(long offset, long[] longs, int low, int number)
          Set a consecutive sequence of longs at the given offset.
 void setShort(long offset, short value)
          Set the short at the given offset.
 void setShorts(long offset, short[] shorts, int low, int number)
          Set a consecutive sequence of shorts at the given offset.
 void unmap()
          Unmap the physical memory range from virtual memory.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RawMemoryAccess

public RawMemoryAccess(Object type,
                       long size)
Constructs a raw memory accessor associated to a memory area of the given memory type and size.

Parameters:
type - the memory type
size - the size of the memory area
Throws:
SecurityException - the current execution context does not have permission to access physical memory, or memory of the given type
SizeOutOfBoundsException - the size is negative or too large
UnsupportedPhysicalMemoryException - the hardware does not support this type of memory
MemoryTypeConflictException - the type parameter's attributes conflict with each other
OutOfMemoryError - the requested type of memory exists, but there is not enough of it to satisfy the request

RawMemoryAccess

public RawMemoryAccess(Object type,
                       long base,
                       long size)
Constructs a raw memory accessor associated to a memory area of the given memory type and size, based at the given offset.

Parameters:
type - the memory type
base - the base offset of the memory area
size - the size of the memory area
Throws:
SecurityException - the current execution context does not have permission to access physical memory, or memory of the given type
OffsetOutOfBoundsException - the address is invalid
SizeOutOfBoundsException - the size is negative or too large
UnsupportedPhysicalMemoryException - the hardware does not support this type of memory
MemoryTypeConflictException - the type parameter's attributes conflict with each other or with the specified base offset
OutOfMemoryError - the requested type of memory exists, but there is not enough of it to satisfy the request
Method Detail

getByte

public byte getByte(long offset)
Get the byte at the given offset.

Parameters:
offset - the memory offset to access
Returns:
the byte at the given offset
Throws:
OffsetOutOfBoundsException - the given offset is negative or outside the range of this raw memory area
SizeOutOfBoundsException - satisfying the request would require accessing storage beyond the end of the memory area

getBytes

public void getBytes(long offset,
                     byte[] bytes,
                     int low,
                     int number)
Get a consecutive sequence of bytes at the given offset.

Parameters:
offset - the memory offset to access
bytes - the array to copy bytes into
low - the offset into the array at which to start copying
number - the number of bytes to copy
Throws:
OffsetOutOfBoundsException - the given offset is negative or outside the range of this raw memory area
SizeOutOfBoundsException - satisfying the request would require accessing storage beyond the end of the memory area

getInt

public int getInt(long offset)
Get the int at the given offset.

Parameters:
offset - the memory offset to access
Returns:
the int at the given offset
Throws:
OffsetOutOfBoundsException - the given offset is negative or outside the range of this raw memory area
SizeOutOfBoundsException - satisfying the request would require accessing storage beyond the end of the memory area

getInts

public void getInts(long offset,
                    int[] ints,
                    int low,
                    int number)
Get a consecutive sequence of ints at the given offset.

Parameters:
offset - the memory offset to access
ints - the array to copy ints into
low - the offset into the array at which to start copying
number - the number of ints to copy
Throws:
OffsetOutOfBoundsException - the given offset is negative or outside the range of this raw memory area
SizeOutOfBoundsException - satisfying the request would require accessing storage beyond the end of the memory area

getLong

public long getLong(long offset)
Get the long at the given offset.

Parameters:
offset - the memory offset to access
Returns:
the long at the given offset
Throws:
OffsetOutOfBoundsException - the given offset is negative or outside the range of this raw memory area
SizeOutOfBoundsException - satisfying the request would require accessing storage beyond the end of the memory area

getLongs

public void getLongs(long offset,
                     long[] longs,
                     int low,
                     int number)
Get a consecutive sequence of longs at the given offset.

Parameters:
offset - the memory offset to access
longs - the array to copy longs into
low - the offset into the array at which to start copying
number - the number of longs to copy
Throws:
OffsetOutOfBoundsException - the given offset is negative or outside the range of this raw memory area
SizeOutOfBoundsException - satisfying the request would require accessing storage beyond the end of the memory area

getShort

public short getShort(long offset)
Get the short at the given offset.

Parameters:
offset - the memory offset to access
Returns:
the short at the given offset
Throws:
OffsetOutOfBoundsException - the given offset is negative or outside the range of this raw memory area
SizeOutOfBoundsException - satisfying the request would require accessing storage beyond the end of the memory area

getShorts

public void getShorts(long offset,
                      short[] shorts,
                      int low,
                      int number)
Get a consecutive sequence of shorts at the given offset.

Parameters:
offset - the memory offset to access
shorts - the array to copy shorts into
low - the offset into the array at which to start copying
number - the number of shorts to copy
Throws:
OffsetOutOfBoundsException - the given offset is negative or outside the range of this raw memory area
SizeOutOfBoundsException - satisfying the request would require accessing storage beyond the end of the memory area

setByte

public void setByte(long offset,
                    byte value)
Set the byte at the given offset.

Parameters:
offset - the memory offset to access
value - the value to assign the byte in memory
Throws:
OffsetOutOfBoundsException - the given offset is negative or outside the range of this raw memory area
SizeOutOfBoundsException - satisfying the request would require accessing storage beyond the end of the memory area

setBytes

public void setBytes(long offset,
                     byte[] bytes,
                     int low,
                     int number)
Set a consecutive sequence of bytes at the given offset.

Parameters:
offset - the memory offset to access
bytes - the array to copy bytes from
low - the offset into the array at which to start copying
number - the number of bytes to copy
Throws:
OffsetOutOfBoundsException - the given offset is negative or outside the range of this raw memory area
SizeOutOfBoundsException - satisfying the request would require accessing storage beyond the end of the memory area

setInt

public void setInt(long offset,
                   int value)
Set the int at the given offset.

Parameters:
offset - the memory offset to access
value - the value to assign the int in memory
Throws:
OffsetOutOfBoundsException - the given offset is negative or outside the range of this raw memory area
SizeOutOfBoundsException - satisfying the request would require accessing storage beyond the end of the memory area

setInts

public void setInts(long offset,
                    int[] ints,
                    int low,
                    int number)
Set a consecutive sequence of ints at the given offset.

Parameters:
offset - the memory offset to access
ints - the array to copy ints from
low - the offset into the array at which to start copying
number - the number of ints to copy
Throws:
OffsetOutOfBoundsException - the given offset is negative or outside the range of this raw memory area
SizeOutOfBoundsException - satisfying the request would require accessing storage beyond the end of the memory area

setLong

public void setLong(long offset,
                    long value)
Set the long at the given offset.

Parameters:
offset - the memory offset to access
value - the value to assign the long in memory
Throws:
OffsetOutOfBoundsException - the given offset is negative or outside the range of this raw memory area
SizeOutOfBoundsException - satisfying the request would require accessing storage beyond the end of the memory area

setLongs

public void setLongs(long offset,
                     long[] longs,
                     int low,
                     int number)
Set a consecutive sequence of longs at the given offset.

Parameters:
offset - the memory offset to access
longs - the array to copy longs from
low - the offset into the array at which to start copying
number - the number of longs to copy
Throws:
OffsetOutOfBoundsException - the given offset is negative or outside the range of this raw memory area
SizeOutOfBoundsException - satisfying the request would require accessing storage beyond the end of the memory area

setShort

public void setShort(long offset,
                     short value)
Set the short at the given offset.

Parameters:
offset - the memory offset to access
value - the value to assign the short in memory
Throws:
OffsetOutOfBoundsException - the given offset is negative or outside the range of this raw memory area
SizeOutOfBoundsException - satisfying the request would require accessing storage beyond the end of the memory area

setShorts

public void setShorts(long offset,
                      short[] shorts,
                      int low,
                      int number)
Set a consecutive sequence of shorts at the given offset.

Parameters:
offset - the memory offset to access
shorts - the array to copy shorts from
low - the offset into the array at which to start copying
number - the number of shorts to copy
Throws:
OffsetOutOfBoundsException - the given offset is negative or outside the range of this raw memory area
SizeOutOfBoundsException - satisfying the request would require accessing storage beyond the end of the memory area

getMappedAddress

public long getMappedAddress()
Returns the virtual memory location at which this physical memory area is mapped.

Returns:
the virtual memory location to which this physical memory area is mapped
Throws:
IllegalStateException - if this RawMemoryAccess is in an unmapped state

map

public long map()
Map the physical memory range into virtual memory.

Returns:
the base address of the mapped region in virtual memory
Throws:
OutOfMemoryError - there is insufficient free virtual memory at the specified address

map

public long map(long base)
Map the physical memory range into virtual memory.

Parameters:
base - the virtual address to map at
Returns:
the base address of the mapped region in virtual memory
Throws:
OutOfMemoryError - there is insufficient free virtual memory at the specified address
IllegalArgumentException - size is negative, or base is an invalid virtual address

map

public long map(long base,
                long size)
Map the physical memory range into virtual memory.

Parameters:
base - the virtual address to map at
size - the size of the block to map
Returns:
the base address of the mapped region in virtual memory
Throws:
OutOfMemoryError - there is insufficient free virtual memory at the specified address
IllegalArgumentException - size is negative, or base is an invalid virtual address

unmap

public void unmap()
Unmap the physical memory range from virtual memory.



jRate is developed and maintained by the jRate project development team.
Copyright (c) 2001-2006 Angelo Corsaro and Morgan Deters.