OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [services/] [memalloc/] [common/] [current/] [include/] [mempoolt.hxx] - Blame information for rev 819

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
#ifndef CYGONCE_KERNEL_MEMPOOLT_HXX
2
#define CYGONCE_KERNEL_MEMPOOLT_HXX
3
 
4
//==========================================================================
5
//
6
//      mempoolt.hxx
7
//
8
//      Mempoolt (Memory pool template) class declarations
9
//
10
//==========================================================================
11
// ####ECOSGPLCOPYRIGHTBEGIN####
12
// -------------------------------------------
13
// This file is part of eCos, the Embedded Configurable Operating System.
14
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
15
//
16
// eCos is free software; you can redistribute it and/or modify it under
17
// the terms of the GNU General Public License as published by the Free
18
// Software Foundation; either version 2 or (at your option) any later
19
// version.
20
//
21
// eCos is distributed in the hope that it will be useful, but WITHOUT
22
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
23
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
24
// for more details.
25
//
26
// You should have received a copy of the GNU General Public License
27
// along with eCos; if not, write to the Free Software Foundation, Inc.,
28
// 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
29
//
30
// As a special exception, if other files instantiate templates or use
31
// macros or inline functions from this file, or you compile this file
32
// and link it with other works to produce a work based on this file,
33
// this file does not by itself cause the resulting work to be covered by
34
// the GNU General Public License. However the source code for this file
35
// must still be made available in accordance with section (3) of the GNU
36
// General Public License v2.
37
//
38
// This exception does not invalidate any other reasons why a work based
39
// on this file might be covered by the GNU General Public License.
40
// -------------------------------------------
41
// ####ECOSGPLCOPYRIGHTEND####
42
//==========================================================================
43
//#####DESCRIPTIONBEGIN####
44
//
45
// Author(s):   hmt
46
// Contributors:        hmt
47
// Date:        1998-02-10
48
// Purpose:     Define Mempoolt class interface
49
 
50
// Description: The class defined here provides the APIs for thread-safe,
51
//              kernel-savvy memory managers; make a class with the
52
//              underlying allocator as the template parameter.
53
// Usage:       #include 
54
//
55
//
56
//####DESCRIPTIONEND####
57
//
58
//==========================================================================
59
 
60
#include 
61
#include          // assertion macros
62
#include 
63
 
64
template 
65
class Cyg_Mempoolt
66
{
67
private:
68
    T pool;                             // underlying memory manager
69
    Cyg_ThreadQueue queue;              // queue of waiting threads
70
 
71
public:
72
 
73
    CYGDBG_DEFINE_CHECK_THIS
74
 
75
    Cyg_Mempoolt(
76
        cyg_uint8 *base,
77
        cyg_int32 size,
78
        CYG_ADDRWORD arg_thru );        // Constructor
79
    ~Cyg_Mempoolt();                    // Destructor
80
 
81
    // get some memory; wait if none available; return NULL if failed
82
    // due to interrupt
83
    cyg_uint8 *alloc( cyg_int32 size );
84
 
85
#ifdef CYGFUN_KERNEL_THREADS_TIMER
86
    // get some memory with a timeout; return NULL if failed
87
    // due to interrupt or timeout
88
    cyg_uint8 *alloc( cyg_int32 size, cyg_tick_count abs_timeout );
89
#endif
90
 
91
    // get some memory, return NULL if none available
92
    cyg_uint8 *try_alloc( cyg_int32 size );
93
 
94
    // free the memory back to the pool
95
    cyg_bool free( cyg_uint8 *p, cyg_int32 size );
96
 
97
    // if applicable: return -1 if not fixed size
98
    cyg_int32 get_blocksize();
99
 
100
    // is anyone waiting for memory?
101
    cyg_bool waiting() { return ! queue.empty(); }
102
 
103
    // these two are obvious and generic
104
    cyg_int32 get_totalmem();
105
    cyg_int32 get_freemem();
106
 
107
    // get information about the construction parameters for external
108
    // freeing after the destruction of the holding object.
109
    void get_arena(
110
        cyg_uint8 * &base,
111
        cyg_int32 &size,
112
        CYG_ADDRWORD &arg_thru );
113
 
114
    // Return the size of the memory allocation (previously returned
115
    // by alloc() or try_alloc() ) at ptr. Returns -1 if not found
116
    cyg_int32
117
    get_allocation_size( cyg_uint8 * /* ptr */ );
118
};
119
 
120
// -------------------------------------------------------------------------
121
#endif // ifndef CYGONCE_KERNEL_MEMPOOLT_HXX
122
// EOF mempoolt.hxx

powered by: WebSVN 2.1.0

© copyright 1999-2025 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.