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

Subversion Repositories openrisc

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
#ifndef CYGONCE_MEMALLOC_MEMFIXED_HXX
2
#define CYGONCE_MEMALLOC_MEMFIXED_HXX
3
 
4
//==========================================================================
5
//
6
//      memfixed.hxx
7
//
8
//      Memory pool with fixed block 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 Memfixed class interface
49
// Description:  Inline class for constructing a fixed block allocator
50
// Usage:        #include 
51
//
52
//
53
//####DESCRIPTIONEND####
54
//
55
//==========================================================================
56
 
57
// CONFIGURATION
58
 
59
#include 
60
#ifdef CYGSEM_MEMALLOC_ALLOCATOR_FIXED_THREADAWARE
61
# include 
62
# ifdef CYGPKG_KERNEL
63
#  include 
64
# endif
65
#endif
66
 
67
 
68
// INCLUDES
69
 
70
#include         // types
71
#include          // assertion macros
72
 
73
#ifdef CYGFUN_KERNEL_THREADS_TIMER
74
# include         // cyg_tick_count
75
#endif
76
 
77
#ifdef CYGSEM_MEMALLOC_ALLOCATOR_FIXED_THREADAWARE
78
# include   // kernel safe mempool template
79
#endif
80
 
81
#include    // implementation of a fixed mem pool
82
#include      // Common memory allocator infra
83
 
84
 
85
// TYPE DEFINITIONS
86
 
87
class Cyg_Mempool_Fixed
88
{
89
protected:
90
#ifdef CYGSEM_MEMALLOC_ALLOCATOR_FIXED_THREADAWARE
91
    Cyg_Mempolt2 mypool;
92
#else
93
    Cyg_Mempool_Fixed_Implementation mypool;
94
#endif
95
 
96
public:
97
    // this API makes concrete a class which implements a thread-safe
98
    // kernel-savvy memory pool which manages fixed size blocks.
99
 
100
    // Constructor: gives the base and size of the arena in which memory is
101
    // to be carved out, note that management structures are taken from the
102
    // same arena.  Alloc_unit is the blocksize allocated.
103
    Cyg_Mempool_Fixed(
104
        cyg_uint8 * /* base */,
105
        cyg_int32 /* size */,
106
        CYG_ADDRWORD /* alloc_unit */ );
107
 
108
    // Destructor
109
    ~Cyg_Mempool_Fixed();
110
 
111
#ifdef CYGSEM_MEMALLOC_ALLOCATOR_FIXED_THREADAWARE
112
    // get some memory; wait if none available
113
    cyg_uint8 *alloc();
114
 
115
# ifdef CYGFUN_KERNEL_THREADS_TIMER
116
    // get some memory with a timeout
117
    cyg_uint8 *alloc( cyg_tick_count /* delay_timeout */ );
118
# endif
119
#endif
120
 
121
    // get some memory, return NULL if none available
122
    cyg_uint8 *try_alloc();
123
 
124
    // supposedly resize existing allocation. This is defined in the
125
    // fixed block allocator purely for API consistency. It will return
126
    // an error (false) for all values, except for the blocksize
127
    // returns true on success
128
    cyg_uint8 *
129
    resize_alloc( cyg_uint8 * /* alloc_ptr */, cyg_int32 /* newsize */,
130
                  cyg_int32 * /* oldsize */ =NULL );
131
 
132
    // free the memory back to the pool
133
    cyg_bool free( cyg_uint8 * /* p */ );
134
 
135
    // Get memory pool status
136
    // flags is a bitmask of requested fields to fill in. The flags are
137
    // defined in common.hxx
138
    void get_status( cyg_mempool_status_flag_t /* flags */,
139
                     Cyg_Mempool_Status & /* status */ );
140
 
141
    CYGDBG_DEFINE_CHECK_THIS
142
};
143
 
144
#endif // ifndef CYGONCE_MEMALLOC_MEMFIXED_HXX
145
// EOF memfixed.hxx

powered by: WebSVN 2.1.0

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