TEndpointBuffer Class Reference

class TEndpointBuffer

This class forms part of the Buffer Interface Layer (BIL), which forms the user side component of the USB Shared Chunk Client. Objects of this type represent the shared chunk buffer, for a given endpoint. The method RDevUsbcScClient::OpenEndpoint() should be used to initialise objects of this type.

Public Member Functions
TEndpointBuffer()
IMPORT_C TIntClose()
IMPORT_C voidDump()
IMPORT_C TIntExpire()
IMPORT_C TIntExpire(TAny *)
IMPORT_C TIntGetBuffer(TAny *&, TUint &, TBool &, TRequestStatus &, TUint)
TInt GetBuffer(TUint &, TUint &, TBool &, TRequestStatus &, TUint)
TInt GetEndpointNumber()
IMPORT_C TIntGetInBufferRange(TAny *&, TUint &)
IMPORT_C TIntGetInBufferRange(TUint &, TUint &)
IMPORT_C TIntTakeBuffer(TAny *&, TUint &, TBool &, TRequestStatus &, TUint)
IMPORT_C TIntWriteBuffer(TAny *, TUint, TBool, TRequestStatus &)
IMPORT_C TIntWriteBuffer(TUint, TUint, TBool, TRequestStatus &)
Private Member Functions
voidConstruct(RDevUsbcScClient *, TUint8 *, const TUsbcScHdrEndpointRecord *, TInt, SUsbcScBufferHeader *)
Private Member Enumerations
enumTDir { EValid = KErrNone, ENotValid = KErrNotSupported, EEOF = KErrEof }
Public Attributes
const TIntKStateChange
Private Attributes
TUint iBaseAddr
TInt iBufferNum
TUint8 *iBufferStartAddr
RDevUsbcScClient *iClient
SUsbcScBufferHeader *iEndpointHdr
TInt iEndpointNumber
TDir iInState
TDir iOutState
TUint iSize

Constructor & Destructor Documentation

TEndpointBuffer()

IMPORT_CTEndpointBuffer()

Member Functions Documentation

Close()

IMPORT_C TIntClose()

This method closes the endpoint, after it was opened with RDevUsbcScClient::OpenEndpoint(...). No method of this object can be used after this call, until RDevUsbcScClient::OpenEndpoint(...) is called on it again.

Closes the endpoint buffer

Construct(RDevUsbcScClient *, TUint8 *, const TUsbcScHdrEndpointRecord *, TInt, SUsbcScBufferHeader *)

voidConstruct(RDevUsbcScClient *aClient,
TUint8 *aBaseAddr,
const TUsbcScHdrEndpointRecord *aEpType,
TIntaEndpointNumber,
SUsbcScBufferHeader *aEndpointHdr = NULL
)[private]

Parameters

RDevUsbcScClient * aClient
TUint8 * aBaseAddr
const TUsbcScHdrEndpointRecord * aEpType
TInt aEndpointNumber
SUsbcScBufferHeader * aEndpointHdr = NULL

Dump()

IMPORT_C voidDump()

Expire()

IMPORT_C TIntExpire()

Used in conjunction with TakeBuffer method. This will make the 'oldest' block of data previously read out using the TakeBuffer method, but not already expired, to be released back to the system. This block can then be overwritten with new data, when it becomes available.

Expire(TAny *)

IMPORT_C TIntExpire(TAny *aAddress)

Used in conjunction with TakeBuffer method. This function allows blocks to be expired in a different order from which the user read the data out of the buffer. Note that the system will only reuse blocks up to the point of the oldest non-expired block read. This means that the user must ensure to expire all blocks in a timely manner to prevent the system from running out of usable memory.

Parameters

TAny * aAddressaAddress is the start address of the block of data previously read by the user which can be overwritten.

GetBuffer(TAny *&, TUint &, TBool &, TRequestStatus &, TUint)

IMPORT_C TIntGetBuffer(TAny *&aBuffer,
TUint &aSize,
TBool &aZLP,
TRequestStatus &aStatus,
TUintaLength = 0
)

Read the next block of data from the Shared chunk buffer. This method should be used if the user wishes to process one block of data at a time. This method also expires the previously read block, meaning that the memory used by the block of data may be re-used by the system, overwriting it with new data.

Parameters

TAny *& aBufferaBuffer will point to data location in shared chunk
TUint & aSizeaSize will hold the number of valid bytes that can be read
TBool & aZLPaZLP will indicate whether its a short packet or not
TRequestStatus & aStatusIn case of no data available to be read, aStatus will be passed on to LDD, and user side should wait for asynchronous call ReadDataNotify to return
TUint aLength = 0Not used at the moment

GetBuffer(TUint &, TUint &, TBool &, TRequestStatus &, TUint)

TInt GetBuffer(TUint &aOffset,
TUint &aSize,
TBool &aZLP,
TRequestStatus &aStatus,
TUintaLength = 0
)[inline]

Read the next block of data from the Shared chunk buffer. This method should be used if the user wishes to process one block of data at a time. This method also expires the previously read block, meaning that the memory used by the block of data may be re-used by the system, overwriting it with new data.

Parameters

TUint & aOffsetaOffset will point to data offset in shared chunk
TUint & aSizeaSize will hold the number of valid bytes that can be read
TBool & aZLPaZLP will indicate whether its a short packet or not
TRequestStatus & aStatusIn case of no data available to be read, aStatus will be passed on to LDD, and user side should wait for asynchronous call ReadDataNotify to return
TUint aLength = 0Not used at the moment

GetEndpointNumber()

TInt GetEndpointNumber()[inline]

Used to retrieve the endpoint number for which this object was open on.

GetInBufferRange(TAny *&, TUint &)

IMPORT_C TIntGetInBufferRange(TAny *&aStart,
TUint &aSize
)

For IN endpoints, this method retrieves the geometry for the buffer, for which the caller should stay within, when using the WriteBuffer method.

Parameters

TAny *& aStartA pointer, which is set to point to the start of the buffer.
TUint & aSizeAn TUint for which the size (in bytes) of buffer, is written into.

GetInBufferRange(TUint &, TUint &)

IMPORT_C TIntGetInBufferRange(TUint &aStart,
TUint &aSize
)

For IN endpoints, this method retrieves the geometry for the buffer, for which the caller should stay within, when using the WriteBuffer method.

Parameters

TUint & aStartA TUint for which the buffer's start offset from the start of the chunk, in written into.
TUint & aSizeAn TUint for which the size (in bytes) of buffer, is written into.

TakeBuffer(TAny *&, TUint &, TBool &, TRequestStatus &, TUint)

IMPORT_C TIntTakeBuffer(TAny *&aBuffer,
TUint &aSize,
TBool &aZLP,
TRequestStatus &aStatus,
TUintaLength = 0
)

Read the next block of data from the Shared chunk buffer. This method should be used if the user wishes to process more than one block of data simultaneously. The user must call one of the Expire() methods to free the memory used by the block of data, and make it available for new data.

Parameters

TAny *& aBufferaBuffer will point to data location in shared chunk
TUint & aSizeaSize will hold the number of valid bytes that can be read
TBool & aZLPaZLP will indicate whether its a short packet or not
TRequestStatus & aStatusIn case of no data available to be read, aStatus will be passed on to LDD, and user side should wait for asynchronous call ReadDataNotify to return
TUint aLength = 0Not used at the moment

WriteBuffer(TAny *, TUint, TBool, TRequestStatus &)

IMPORT_C TIntWriteBuffer(TAny *aBuffer,
TUintaSize,
TBoolaZLP,
TRequestStatus &aStatus
)

Initiates write operation.

Parameters

TAny * aBufferaBuffer will point to data in shared chunk to be written out. aBuffer should be aligned
TUint aSizeaSize will hold the number of valid bytes to be written out
TBool aZLPaZLP will indicate whether a ZLP should be transmitted after writing the data out
TRequestStatus & aStatusThis is an asynchronous function and user side should wait on status to know the end of write operation

WriteBuffer(TUint, TUint, TBool, TRequestStatus &)

IMPORT_C TIntWriteBuffer(TUintaOffset,
TUintaSize,
TBoolaZLP,
TRequestStatus &aStatus
)

Initiates write operation.

Parameters

TUint aOffsetaOffset will point to offset of data in shared chunk to be written out.
TUint aSizeaSize will hold the number of valid bytes to be written out
TBool aZLPaZLP will indicate whether a ZLP should be transmitted after writing the data out
TRequestStatus & aStatusThis is an asynchronous function and user side should wait on status to know the end of write operation

Member Enumerations Documentation

Enum TDir

Enumerators

EValid = KErrNone
ENotValid = KErrNotSupported
EEOF = KErrEof

Member Data Documentation

const TInt KStateChange

const TIntKStateChange[static]

This return value used by GetBuffer indicates that the item pointed to by aBuffer/aOffset represents a state change, instead of endpoint data.

TUint iBaseAddr

TUint iBaseAddr[private]

Parent RDevUsbcScClient object

TInt iBufferNum

TInt iBufferNum[private]

associated endpoint number

TUint8 * iBufferStartAddr

TUint8 *iBufferStartAddr[private]

Pointer to the buffer Header for OUT/BI endpoints

RDevUsbcScClient * iClient

RDevUsbcScClient *iClient[private]

buffer number within shared chunk

SUsbcScBufferHeader * iEndpointHdr

SUsbcScBufferHeader *iEndpointHdr[private]

The address of the beginning of the Ldd's chunk

TInt iEndpointNumber

TInt iEndpointNumber[private]

describes state of endpoint, KErrNone if OUT endpoint and ready to use, KErrNotSupportd if not an OUT endpoint, KErrEoF on alternate setting change

TDir iInState

TDir iInState[private]

TDir iOutState

TDir iOutState[private]

describes state of endpoint, KErrNone if IN endpoint and ready to use, KErrNotSupportd if not an IN endpoint, KErrEof on alternate setting change

TUint iSize

TUint iSize[private]

IN/BI endpoint buffer start address within shared chunk