RChunk Class Reference

class RChunk : public RHandleBase

A handle to a chunk.

The chunk itself is a kernel side object.

Inherits from

Public Member Functions
IMPORT_C TIntAdjust(TInt)
IMPORT_C TIntAdjustDoubleEnded(TInt, TInt)
IMPORT_C TIntAllocate(TInt)
IMPORT_C TUint8 *Base()
IMPORT_C TIntBottom()
IMPORT_C TIntCommit(TInt, TInt)
IMPORT_C TIntCreate(TChunkCreateInfo &)
IMPORT_C TIntCreateDisconnectedGlobal(const TDesC &, TInt, TInt, TInt, TOwnerType)
IMPORT_C TIntCreateDisconnectedLocal(TInt, TInt, TInt, TOwnerType)
IMPORT_C TIntCreateDoubleEndedGlobal(const TDesC &, TInt, TInt, TInt, TOwnerType)
IMPORT_C TIntCreateDoubleEndedLocal(TInt, TInt, TInt, TOwnerType)
IMPORT_C TIntCreateGlobal(const TDesC &, TInt, TInt, TOwnerType)
IMPORT_C TIntCreateLocal(TInt, TInt, TOwnerType)
IMPORT_C TIntCreateLocalCode(TInt, TInt, TOwnerType)
IMPORT_C TIntDecommit(TInt, TInt)
IMPORT_C TBoolIsPaged()
TBool IsReadable()
TBool IsWritable()
IMPORT_C TIntLock(TInt, TInt)
IMPORT_C TIntMaxSize()
TInt Open(const TFindChunk &, TOwnerType)
IMPORT_C TIntOpen(RMessagePtr2, TInt, TBool, TOwnerType)
IMPORT_C TIntOpen(TInt, TOwnerType)
IMPORT_C TIntOpenGlobal(const TDesC &, TBool, TOwnerType)
IMPORT_C TIntSetRestrictions(TUint)
IMPORT_C TIntSize()
IMPORT_C TIntTop()
IMPORT_C TIntUnlock(TInt, TInt)
Inherited Functions
RHandleBase::Attributes()const
RHandleBase::BTraceId()const
RHandleBase::Close()
RHandleBase::DoExtendedClose()
RHandleBase::Duplicate(const RThread &,TOwnerType)
RHandleBase::FullName()const
RHandleBase::FullName(TDes &)const
RHandleBase::Handle()const
RHandleBase::HandleInfo(THandleInfo *)
RHandleBase::Name()const
RHandleBase::NotifyDestruction(TRequestStatus &)
RHandleBase::Open(const TFindHandleBase &,TOwnerType)
RHandleBase::OpenByName(const TDesC &,TOwnerType,TInt)
RHandleBase::RHandleBase()
RHandleBase::RHandleBase(TInt)
RHandleBase::SetHandle(TInt)
RHandleBase::SetHandleNC(TInt)
RHandleBase::SetReturnedHandle(TInt)
RHandleBase::SetReturnedHandle(TInt,RHandleBase &)
Public Member Enumerations
enumTRestrictions { EPreventAdjust = 0x01 }
Inherited Enumerations
RHandleBase:TAttributes
Inherited Attributes
RHandleBase::iHandle

Member Functions Documentation

Adjust(TInt)

IMPORT_C TIntAdjust(TIntaNewSize)const

Changes the number of bytes committed to the chunk.

This value is always rounded up to the next nearest processor page boundary.

panic
USER 102 if aNewSize is negative.

Parameters

TInt aNewSizeThe number of bytes to be committed to this chunk.

AdjustDoubleEnded(TInt, TInt)

IMPORT_C TIntAdjustDoubleEnded(TIntaBottom,
TIntaTop
)const

Changes the number of bytes and the position of this double ended chunk's committed region.

The difference between aTop and aBottom gives the new size of the committed region; aBottom gives the offset of the bottom of the committed region from the base of the chunk's reserved region.

Both aBottom and aTop are rounded up to the next nearest processor page boundary.

The function fails if this chunk is not a double ended chunk; for a standard chunk, use the Adjust() function.

Note that if the initial and final committed regions intersect, the contents of the intersection are unchanged. Other parts of the committed region have undefined contents.

Note also that:

1. the lowest valid address in a double ended chunk is the sum of the base of the chunk's reserved region plus the adjusted value of aBottom

2. the highest valid address in a double ended chunk is the the sum of the base of the chunk's reserved region plus the adjusted value of aTop - 1.

panic
USER 124 if aBottom is negative.
panic
USER 125 if aTop is negative.
panic
USER 126 if aBottom is greater than the supplied value of aTop.

Parameters

TInt aBottomThe offset from the base of the chunk of the bottom of the committed region.
TInt aTopThe offset from the base of the chunk of the top of the committed region.

Allocate(TInt)

IMPORT_C TIntAllocate(TIntaSize)const

Allocates and commits to a disconnected chunk.

panic
USER 159 if aSize is negative.

Parameters

TInt aSizeThe size of the committed region.

Base()

IMPORT_C TUint8 *Base()const

Gets a pointer to the base of the chunk's reserved region.

Bottom()

IMPORT_C TIntBottom()const

Gets the offset of the bottom of the double ended chunk's committed region from the base of the chunk's reserved region.

Note that the lowest valid address in a double ended chunk is the sum of the base of the chunk's reserved region plus the value of Bottom().

Commit(TInt, TInt)

IMPORT_C TIntCommit(TIntanOffset,
TIntaSize
)const

Commits memory to a disconnected chunk.

Memory is committed in blocks of the MMU page size. E.g. Commit(pageSize-1,2) which asks for the last byte of the first page and the first byte of the second page and will result in the first 2 pages in the chunk being committed. For this reason it is best to only use values for aOffset and aSize which are multiples of the MMU page size. This size can be obtained with the following code.
TInt pageSize;
HAL::Get(HAL::EMemoryPageSize,pageSize)
panic
USER 157 if anOffset is negative.
panic
USER 158 if aSize is negative.

Parameters

TInt anOffsetThe offset of the committed region from the base of the chunk's reserved region.
TInt aSizeThe size of the committed region.

Create(TChunkCreateInfo &)

IMPORT_C TIntCreate(TChunkCreateInfo &aCreateInfo)

Creates a chunk of the type specified by the parameter aCreateInfo.

panic
USER 99 if the specified maximum size is negative.
panic
USER 120 if any specified initial bottom is negative.
panic
USER 121 if any specified initial top is negative.
panic
USER 122 if any specified initial bottom is greater than the supplied value for the intial top.
panic
USER 123 if any specified initial top is greater than the supplied value for the maximum size.
panic
USER 214 if any of the specified attributes is invalid.
panic
USER 215 if the version number of aCreateInfo is invalid.

Parameters

TChunkCreateInfo & aCreateInfo

CreateDisconnectedGlobal(const TDesC &, TInt, TInt, TInt, TOwnerType)

IMPORT_C TIntCreateDisconnectedGlobal(const TDesC &aName,
TIntaInitialBottom,
TIntaInitialTop,
TIntaMaxSize,
TOwnerTypeaType = EOwnerProcess
)

Creates a global, disconnected, chunk.

The chunk is global; i.e. it is visible to all processes and is intended for access by other user processes.

A disconnected chunk has a committed region consisting of an arbitrary set of MMU pages within the reserved region, i.e. each page-sized address range within the reserved region which begins on a page boundary may be committed independently.

aMaxSize specifies the maximum size of the chunk.

The difference between aInitialTop and aInitialBottom gives the number of bytes to be committed, on creation of the chunk; aInitialBottom gives the offset of the bottom of the committed region from the base of the chunk's reserved region; aInitialTop gives the offset of the top of the committed region from the base of the chunk's reserved region.

Both aInitialBottom and aInitialTop are rounded up to the next nearest processor page boundary value, if they are not already on a processor page boundary value.

The descriptor aName contains the name to be assigned to this global chunk.

By default, ownership of this chunk handle is vested in the current process. Ownership of the chunk handle can be vested in the current thread by passing EOwnerThread as the third parameter to this function.

panic
USER 99 if aMaxSize is negative.
panic
USER 120 if aInitialBottom is negative.
panic
USER 121 if aInitialTop is negative.
panic
USER 122 if aInitialBottom is greater than the supplied value of aInitialTop.
panic
USER 123 if aInitialTop is greater than the supplied value of aMaxSize.

Parameters

const TDesC & aNameA reference to a descriptor containing the name to be assigned to this global chunk. The length of the descriptor must be no greater than that allowed for a TKName type.
TInt aInitialBottomThe offset of the bottom of the new committed region from the base of the chunk's reserved region.
TInt aInitialTopThe offset of the top of the new committed region from the base of the chunk's reserved region.
TInt aMaxSizeThe maximum size to which the reserved region of this chunk can grow.
TOwnerType aType = EOwnerProcessAn enumeration whose enumerators define the ownership of this chunk handle. If not explicitly specified, EOwnerProcess is taken as default.

CreateDisconnectedLocal(TInt, TInt, TInt, TOwnerType)

IMPORT_C TIntCreateDisconnectedLocal(TIntaInitialBottom,
TIntaInitialTop,
TIntaMaxSize,
TOwnerTypeaType = EOwnerProcess
)

Creates a local, disconnected chunk.

The chunk is local to the process creating it; i.e. it is private to the process creating it and is not intended for access by other user processes.

A disconnected chunk has a committed region consisting of an arbitrary set of MMU pages within the reserved region, i.e. each page-sized address range within the reserved region which begins on a page boundary may be committed independently.

aMaxSize specifies the maximum size of the chunk.

The difference between aInitialTop and aInitialBottom gives the number of bytes to be committed, on creation of the chunk; aInitialBottom gives the offset of the bottom of the committed region from the base of the chunk's reserved region; aInitialTop gives the offset of the top of the committed region from the base of the chunk's reserved region.

Both aInitialBottom and aInitialTop are rounded up to the next nearest processor page boundary value, if they are not already on a processor page boundary value.

By default, ownership of this chunk handle is vested in the current process. Ownership of the chunk handle can be vested in the current thread by passing EOwnerThread as the third parameter to this function.

panic
USER 99 if aMaxSize is negative.
panic
USER 120 if aInitialBottom is negative.
panic
USER 121 if aInitialTop is negative.
panic
USER 122 if aInitialBottom is greater than the supplied value of aInitialTop.
panic
USER 123 if aInitialTop is greater than the supplied value of aMaxSize.

Parameters

TInt aInitialBottomThe offset of the bottom of the new committed region from the base of the chunk's reserved region.
TInt aInitialTopThe offset of the top of the new committed region from the base of the chunk's reserved region.
TInt aMaxSizeThe maximum size to which the reserved region of this chunk can grow.
TOwnerType aType = EOwnerProcessAn enumeration whose enumerators define the ownership of this chunk handle. If not explicitly specified, EOwnerProcess is taken as default.

CreateDoubleEndedGlobal(const TDesC &, TInt, TInt, TInt, TOwnerType)

IMPORT_C TIntCreateDoubleEndedGlobal(const TDesC &aName,
TIntaInitialBottom,
TIntaInitialTop,
TIntaMaxSize,
TOwnerTypeaType = EOwnerProcess
)

Creates a global, double ended, chunk.

The chunk is global; i.e. it is visible to all processes and is intended for access by other user processes.

The committed region of a double ended chunk can be any contiguous subset of the reserved region.

aMaxSize specifies the maximum size of the chunk.

The difference between aInitialTop and aInitialBottom gives the number of bytes to be committed, on creation of the chunk; aInitialBottom gives the offset of the bottom of the committed region from the base of the chunk's reserved region; aInitialTop gives the offset of the top of the committed region from the base of the chunk's reserved region.

Both aInitialBottom and aInitialTop are rounded up to the next nearest processor page boundary value, if they are not already on a processor page boundary value.

The descriptor aName contains the name to be assigned to this global chunk.

By default, ownership of this chunk handle is vested in the current process. Ownership of the chunk handle can be vested in the current thread by passing EOwnerThread as the third parameter to this function.

Note that:

1. the lowest valid address in a double ended chunk is the sum of the base of the chunk's reserved region plus the adjusted value of aInitialBottom

2. the highest valid address in a double ended chunk is the the sum of the base of the chunk's reserved region plus the adjusted value of aInitialTop - 1.

panic
USER 99 if aMaxSize is negative.
panic
USER 120 if aInitialBottom is negative.
panic
USER 121 if aInitialTop is negative.
panic
USER 122 if aInitialBottom is greater than the supplied value of aInitialTop.
panic
USER 123 if aInitialTop is greater than the supplied value of aMaxSize.
panic
USER 163 if aName is empty.

Parameters

const TDesC & aNameA reference to a descriptor containing the name to be assigned to this global chunk. The length of the descriptor must be no greater than that allowed for a TKName type.
TInt aInitialBottomThe offset of the bottom of the new committed region from the base of the chunk's reserved region.
TInt aInitialTopThe offset of the top of the new committed region from the base of the chunk's reserved region.
TInt aMaxSizeThe maximum size to which the reserved region of this chunk can grow.
TOwnerType aType = EOwnerProcessAn enumeration whose enumerators define the ownership of this chunk handle. If not explicitly specified, EOwnerProcess is taken as default.

CreateDoubleEndedLocal(TInt, TInt, TInt, TOwnerType)

IMPORT_C TIntCreateDoubleEndedLocal(TIntaInitialBottom,
TIntaInitialTop,
TIntaMaxSize,
TOwnerTypeaType = EOwnerProcess
)

Creates a local, double ended, chunk.

The chunk is local to the process creating it; i.e. it is private to the process creating it and is not intended for access by other user processes.

The committed region of a double ended chunk can be any contiguous subset of the reserved region.

aMaxSize specifies the maximum size of the chunk.

The difference between aInitialTop and aInitialBottom gives the number of bytes to be committed, on creation of the chunk; aInitialBottom gives the offset of the bottom of the committed region from the base of the chunk's reserved region; aInitialTop gives the offset of the top of the committed region from the base of the chunk's reserved region.

Both aInitialBottom and aInitialTop are rounded up to the next nearest processor page boundary value, if they are not already on a processor page boundary value.

By default, ownership of this chunk handle is vested in the current process. Ownership of the chunk handle can be vested in the current thread by passing EOwnerThread as the third parameter to this function.

Note that:

1. the lowest valid address in a double ended chunk is the sum of the base of the chunk's reserved region plus the adjusted value of aInitialBottom

2. the highest valid address in a double ended chunk is the the sum of the base of the chunk's reserved region plus the adjusted value of aInitialTop - 1.

panic
USER 99 if aMaxSize is negative.
panic
USER 120 if aInitialBottom is negative.
panic
USER 121 if aInitialTop is negative.
panic
USER 122 if aInitialBottom is greater than the supplied value of aInitialTop.
panic
USER 123 if aInitialTop is greater than the supplied value of aMaxSize.

Parameters

TInt aInitialBottomThe offset of the bottom of the new committed region from the base of the chunk's reserved region.
TInt aInitialTopThe offset of the top of the new committed region from the base of the chunk's reserved region.
TInt aMaxSizeThe maximum size to which the reserved region of this chunk can grow.
TOwnerType aType = EOwnerProcessAn enumeration whose enumerators define the ownership of this chunk handle. If not explicitly specified, EOwnerProcess is taken as default.

CreateGlobal(const TDesC &, TInt, TInt, TOwnerType)

IMPORT_C TIntCreateGlobal(const TDesC &aName,
TIntaSize,
TIntaMaxSize,
TOwnerTypeaType = EOwnerProcess
)

Creates a global chunk.

The chunk is global; i.e. it is potentially visible to all processes and is intended for access by other user processes.

aMaxSize specifies the maximum size of the chunk and aSize specifies the number of bytes to be committed on creation of the chunk. Both values are rounded up to the next nearest processor page boundary value ,if they are not already on a processor page boundary value.

The committed region always starts at the bottom of the reserved region.

The descriptor aName contains the name to be assigned to this global chunk. If this name is empty, the chunk will be anonymous. Anonymous chunks cannot be accessed by other processes unless the creator explicitly passes them a handle to the chunk - this can be used to transfer large amounts of data between processes in a secure fashion.

By default, ownership of this chunk handle is vested in the current process. Ownership of the chunk handle can be vested in the current thread by passing EOwnerThread as the third parameter to this function.

panic
USER 99 if aMaxSize is negative.
panic
USER 100 if aSize is negative.
panic
USER 101 if aSize is greater than or equal to the supplied value of aMaxSize.

Parameters

const TDesC & aNameA reference to a descriptor containing the name to be assigned to this global chunk. The length of the descriptor must be no greater than that allowed for a TKName type.
TInt aSizeThe number of bytes committed to this chunk.
TInt aMaxSizeThe maximum size to which the reserved region of this chunk can grow.
TOwnerType aType = EOwnerProcessAn enumeration whose enumerators define the ownership of this chunk handle. If not explicitly specified, EOwnerProcess is taken as default.

CreateLocal(TInt, TInt, TOwnerType)

IMPORT_C TIntCreateLocal(TIntaSize,
TIntaMaxSize,
TOwnerTypeaType = EOwnerProcess
)

Creates a local chunk.

The chunk is local to the process creating it; i.e. it is private to the process creating it and is not intended for access by other user processes.

aMaxSize specifies the maximum size of the chunk and aSize specifies the number of bytes to be committed on creation of the chunk. Both values are rounded up to the next nearest processor page boundary value if they are not already on a processor page boundary.

The committed region always starts at the bottom of the reserved region.

By default, ownership of this chunk handle is vested in the current process. Ownership of the chunk handle can be vested in the current thread by passing EOwnerThread as the third parameter to this function.

panic
USER 99 if aMaxSize is negative.
panic
USER 100 if aSize is negative.
panic
USER 101 if aSize is greater than or equal to the supplied value of aMaxSize.

Parameters

TInt aSizeThe number of bytes committed to this chunk.
TInt aMaxSizeThe maximum size to which the reserved region of this chunk can grow.
TOwnerType aType = EOwnerProcessAn enumeration whose enumerators define the ownership of this chunk handle. If not explicitly specified, EOwnerProcess is taken as default.

CreateLocalCode(TInt, TInt, TOwnerType)

IMPORT_C TIntCreateLocalCode(TIntaSize,
TIntaMaxSize,
TOwnerTypeaType = EOwnerProcess
)

Creates a user writable chunk that is marked by the kernel as containing code.

The chunk is local to the process creating it, i.e. it is private to the process creating it and is not intended for access by other user processes.

On systems using a Harvard cache, this type of chunk removes the need to flush the instruction cache (I-Cache) on a context switch. However, the instruction Translation Look-aside Buffer (ITLB) still needs to be flushed when switching to or from a process with one of these chunks in its address space. Systems with a dynamic branch predictor may also need to flush their branch target buffer when switching from one process using this type of chunk to another.

panic
USER 99 if aMaxSize is negative.
panic
USER 100 if aSize is negative.
panic
USER 101 if aSize is greater than or equal to the supplied value of aMaxSize.
UserHeap::ChunkHeap User::IMB_Range

Parameters

TInt aSizeThe number of bytes committed to this chunk.
TInt aMaxSizeThe maximum size to which the reserved region of this chunk can grow.
TOwnerType aType = EOwnerProcessAn enumeration whose enumerators define the ownership of this chunk handle. If not explicitly specified, EOwnerProcess is taken as default.

Decommit(TInt, TInt)

IMPORT_C TIntDecommit(TIntanOffset,
TIntaSize
)const

Decommits memory from a disconnected chunk.

Memory is decommitted in blocks of the MMU page size. E.g. Decommit(pageSize-1,2) which asks for the last byte of the first page and the first byte of the second page and will result in the first 2 pages in the chunk being decommitted. For this reason it is best to only use values for aOffset and aSize which are multiples of the MMU page size. This size can be obtained with the following code.
TInt pageSize;
HAL::Get(HAL::EMemoryPageSize,pageSize)
panic
USER 160 if anOffset is negative.
panic
USER 161 if aSize is negative.

Parameters

TInt anOffsetThe offset of the committed region from the base of the chunk's reserved region;
TInt aSizeThe size of the committed region.

IsPaged()

IMPORT_C TBoolIsPaged()const

This can be used to determine whether the data for the chunk is demand paged or not.

IsReadable()

TBool IsReadable()const [inline]

Tests whether the chunk is mapped into its process address space.

IsWritable()

TBool IsWritable()const [inline]

Tests whether the chunk mapped into its process address space and is writable.

Lock(TInt, TInt)

IMPORT_C TIntLock(TIntaOffset,
TIntaSize
)

Parameters

TInt aOffset
TInt aSize

MaxSize()

IMPORT_C TIntMaxSize()const

Gets the maximum size of this chunk.

This maximum size of this chunk is set when the chunk is created.

Open(const TFindChunk &, TOwnerType)

TInt Open(const TFindChunk &aFind,
TOwnerTypeaType = EOwnerProcess
)[inline]

Opens a handle to the global chunk found using a TFindChunk object.

A TFindChunk object is used to find all chunks whose full names match a specified pattern.

By default, ownership of this chunk handle is vested in the current process, but can be vested in the current thread by passing EOwnerThread as the second parameter to this function.

Parameters

const TFindChunk & aFindA reference to the TFindChunk object used to find the chunk.
TOwnerType aType = EOwnerProcessAn enumeration whose enumerators define the ownership of this chunk handle. If not explicitly specified, EOwnerProcess is taken as default.

Open(RMessagePtr2, TInt, TBool, TOwnerType)

IMPORT_C TIntOpen(RMessagePtr2aMessage,
TIntaParam,
TBoolisReadOnly,
TOwnerTypeaType = EOwnerProcess
)

Opens a handle to a chunk using a handle number sent by a client to a server.

This function is called by the server.

Parameters

RMessagePtr2 aMessageThe message pointer.
TInt aParamAn index specifying which of the four message arguments contains the handle number.
TBool isReadOnlyThis is currently not implemented and setting it to ETrue will have no effect. (Intended implementation will be as below: Defines the type of access to the chunk: Specify ETrue if access is limited to read only, otherwise specify EFalse for full read/write access.)
TOwnerType aType = EOwnerProcessAn enumeration whose enumerators define the ownership of this chunk handle. If not explicitly specified, EOwnerProcess is taken as default.

Open(TInt, TOwnerType)

IMPORT_C TIntOpen(TIntaArgumentIndex,
TOwnerTypeaType = EOwnerProcess
)

Opens a handle to a chunk using a handle number passed as an environment data item to the child process during the creation of that child process.

Note that this function can only be called successfully once.

RProcess::SetParameter()

Parameters

TInt aArgumentIndexAn index that identifies the slot in the process environment data that contains the handle number. This is a value relative to zero, i.e. 0 is the first item/slot. This can range from 0 to 15.
TOwnerType aType = EOwnerProcessAn enumeration whose enumerators define the ownership of this chunk handle. If not explicitly specified, EOwnerProcess is taken as default.

OpenGlobal(const TDesC &, TBool, TOwnerType)

IMPORT_C TIntOpenGlobal(const TDesC &aName,
TBoolisReadOnly,
TOwnerTypeaType = EOwnerProcess
)

Opens a handle to a specific named global chunk.

Full read/write access can be allowed or access can be limited to read only.

By default, ownership of this process handle is vested in the current process, but can be vested in the current thread by passing EOwnerThread as the second parameter to this function.

Parameters

const TDesC & aNameA reference to the descriptor containing the name of the chunk to be opened.
TBool isReadOnlyThis is currently not implemented and setting it to ETrue will have no effect. (Intended implementation will be as below: Defines the type of access to the chunk: Specify ETrue if access is limited to read only, otherwise specify EFalse for full read/write access.)
TOwnerType aType = EOwnerProcessAn enumeration whose enumerators define ownership of this chunk handle. If not explicitly specified, EOwnerProcess is taken as default.

SetRestrictions(TUint)

IMPORT_C TIntSetRestrictions(TUintaFlags)

Sets or removes restrictions on the ability of the chunk to change.

For example, to adjust, commit etc

RChunk::TRestrictions()

Parameters

TUint aFlagsOne of the values defined by TRestrictions.

Size()

IMPORT_C TIntSize()const

Gets the current size of this chunk's committed region.

Top()

IMPORT_C TIntTop()const

Gets the offset of the top of the double ended chunk's committed region from the base of the chunk's reserved region.

Note that the highest valid address in a double ended chunk is the the sum of the base of the chunk's reserved region plus the value of Top() - 1.

Unlock(TInt, TInt)

IMPORT_C TIntUnlock(TIntaOffset,
TIntaSize
)

Parameters

TInt aOffset
TInt aSize

Member Enumerations Documentation

Enum TRestrictions

Enumerators

EPreventAdjust = 0x01

Prevent Adjust, Commit, Allocate and Decommit