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

Subversion Repositories openrisc

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
#ifndef CYGONCE_MEMALLOC_MEMPOLT2_HXX
2
#define CYGONCE_MEMALLOC_MEMPOLT2_HXX
3
 
4
//==========================================================================
5
//
6
//      mempolt2.hxx
7
//
8
//      Mempolt2 (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: jlarmour
47
// Date:         2000-06-12
48
// Purpose:      Define Mempolt2 class interface
49
// Description:  The class defined here provides the APIs for thread-safe,
50
//               kernel-savvy memory managers; make a class with the
51
//               underlying allocator as the template parameter.
52
// Usage:        #include 
53
//
54
//
55
//####DESCRIPTIONEND####
56
//
57
//==========================================================================
58
 
59
// It is assumed that implementations using this file have already mandated
60
// that the kernel is present. So we just go ahead and use it
61
 
62
#include 
63
#include 
64
#include          // assertion macros
65
#include 
66
#include      // Common memory allocator infra
67
 
68
template 
69
class Cyg_Mempolt2
70
{
71
private:
72
    T pool;                             // underlying memory manager
73
    Cyg_ThreadQueue queue;              // queue of waiting threads
74
 
75
    class Mempolt2WaitInfo {
76
    private:
77
        Mempolt2WaitInfo() {}
78
    public:
79
        cyg_int32 size;
80
        cyg_uint8 *addr;
81
        Mempolt2WaitInfo( cyg_int32 allocsize )
82
        { size = allocsize; addr = 0; }
83
    };
84
 
85
public:
86
 
87
    Cyg_Mempolt2(
88
        cyg_uint8 *base,
89
        cyg_int32 size,
90
        CYG_ADDRWORD arg_thru );        // Constructor
91
    ~Cyg_Mempolt2();                    // Destructor
92
 
93
    // get some memory; wait if none available; return NULL if failed
94
    // due to interrupt
95
    cyg_uint8 *alloc( cyg_int32 size );
96
 
97
#ifdef CYGFUN_KERNEL_THREADS_TIMER
98
    // get some memory with a timeout; return NULL if failed
99
    // due to interrupt or timeout
100
    cyg_uint8 *alloc( cyg_int32 size, cyg_tick_count abs_timeout );
101
#endif
102
 
103
    // get some memory, return NULL if none available
104
    cyg_uint8 *try_alloc( cyg_int32 size );
105
 
106
    // resize existing allocation, if oldsize is non-NULL, previous
107
    // allocation size is placed into it. If previous size not available,
108
    // it is set to 0. NB previous allocation size may have been rounded up.
109
    // Occasionally the allocation can be adjusted *backwards* as well as,
110
    // or instead of forwards, therefore the address of the resized
111
    // allocation is returned, or NULL if no resizing was possible.
112
    // Note that this differs from ::realloc() in that no attempt is
113
    // made to call malloc() if resizing is not possible - that is left
114
    // to higher layers. The data is copied from old to new though.
115
    // The effects of alloc_ptr==NULL or newsize==0 are undefined
116
    cyg_uint8 *
117
    resize_alloc( cyg_uint8 *alloc_ptr, cyg_int32 newsize,
118
                  cyg_int32 *oldsize );
119
 
120
    // free the memory back to the pool
121
    // returns true on success
122
    cyg_bool free( cyg_uint8 *p, cyg_int32 size );
123
 
124
    // Get memory pool status
125
    // flags is a bitmask of requested fields to fill in. The flags are
126
    // defined in common.hxx
127
    void get_status( cyg_mempool_status_flag_t flags,
128
                     Cyg_Mempool_Status &status );
129
 
130
    CYGDBG_DEFINE_CHECK_THIS
131
 
132
};
133
 
134
#include 
135
 
136
// -------------------------------------------------------------------------
137
#endif // ifndef CYGONCE_MEMALLOC_MEMPOLT2_HXX
138
// EOF mempolt2.hxx

powered by: WebSVN 2.1.0

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