systemswstubs/examplecommonisc/IscDataTransmissionBase/inc/IscBufferAllocator.h
changeset 39 65e91466a14b
parent 31 931072794a66
child 40 b7e5ed8c1342
equal deleted inserted replaced
31:931072794a66 39:65e91466a14b
     1 /*
       
     2 * Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Reference implementation for ISC buffer allocator.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 #ifndef ISCBUFFERALLOCATOR_H
       
    22 #define ISCBUFFERALLOCATOR_H
       
    23 
       
    24 //  INCLUDES
       
    25 #include <kernel.h>
       
    26 
       
    27 #include "IscDataTransmissionBase.h"
       
    28 
       
    29 // CONSTANTS
       
    30 
       
    31 // MACROS
       
    32 
       
    33 // DATA TYPES
       
    34 
       
    35 // FUNCTION PROTOTYPES
       
    36 
       
    37 // FORWARD DECLARATIONS
       
    38 class DIscDevice;
       
    39 class IscBufferQueue;
       
    40 class DPlatChunkHw;
       
    41 class DIscBufferQueue;
       
    42 
       
    43 // CLASS DECLARATION
       
    44 
       
    45 
       
    46 /**
       
    47 *  Manages pre-allocated memory blocks
       
    48 *
       
    49 *  @lib IscDataTransmissionBase.LIB
       
    50 *  @since 2.8
       
    51 */
       
    52 class DIscBufferAllocator //: public DLogicalDevice
       
    53     {
       
    54     public:  // Constructors and destructor
       
    55         
       
    56         DIscBufferAllocator( TIscBufferEntry* aBufferConfig );
       
    57         virtual ~DIscBufferAllocator();
       
    58 
       
    59     public: // New functions
       
    60         
       
    61         /**
       
    62         * This method reserves pre-allocated memory block for sending/receiving frames
       
    63         * @since 2.8
       
    64         * @param TDes8*& aPtr a reference to pointer of descriptor
       
    65         * @param TUint16 aSize The minimum size of needed memory block
       
    66         * @return void 
       
    67         */
       
    68         IMPORT_C void ReserveMemoryBlock( TDes8*& aPtr, TUint16 aSize );
       
    69         
       
    70         /**
       
    71         * This method releases memory block allocated with ReserveMemoryBlock
       
    72         * @since 2.8
       
    73         * @param TDes8* aPtr a pointer to descriptor that is to be released
       
    74         * @return void 
       
    75         */
       
    76         IMPORT_C void ReleaseMemoryBlock( TDes8* aPtr );
       
    77 
       
    78         /**
       
    79         * This method makes the buffer allocations according to the 
       
    80         * configuration specified by the ISC Multiplexer
       
    81         * @since 2.8
       
    82         * @return TInt KErrNone if succesful
       
    83         */
       
    84         IMPORT_C TInt AllocBuffers();
       
    85 
       
    86 
       
    87     private:
       
    88 
       
    89         /**
       
    90         * This method makes the physical buffer allocations 
       
    91         * @since 2.8
       
    92         * @param TInt aPages amount of needed pages to allocate
       
    93         * @return void 
       
    94         */
       
    95         void AllocPhMemory( TInt aPages );
       
    96 
       
    97     private:    // Data
       
    98 
       
    99         TIscBufferEntry    iBufferConfig[KIscBufferAmount];
       
   100         DIscBufferQueue**   iBuffers;
       
   101         
       
   102 #ifndef __WINS__
       
   103         DPlatChunkHw* iBufferChunk;
       
   104         TLinAddr    iCurrentAddress;
       
   105 #endif
       
   106 
       
   107     };
       
   108 
       
   109 #endif      // ISCBUFFERALLOCATOR
       
   110             
       
   111 // End of File