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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [ecos-2.0/] [packages/] [services/] [memalloc/] [common/] [v2_0/] [include/] [kapi.h] - Blame information for rev 1254

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

Line No. Rev Author Line
1 1254 phoenix
#ifndef CYGONCE_MEMALLOC_KAPI_H
2
#define CYGONCE_MEMALLOC_KAPI_H
3
 
4
/*==========================================================================
5
//
6
//      kapi.h
7
//
8
//      Memory allocator portion of kernel C API
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 Red Hat, 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 version.
19
//
20
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
21
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
22
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
23
// for more details.
24
//
25
// You should have received a copy of the GNU General Public License along
26
// with eCos; if not, write to the Free Software Foundation, Inc.,
27
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
28
//
29
// As a special exception, if other files instantiate templates or use macros
30
// or inline functions from this file, or you compile this file and link it
31
// with other works to produce a work based on this file, this file does not
32
// by itself cause the resulting work to be covered by the GNU General Public
33
// License. However the source code for this file must still be made available
34
// in accordance with section (3) of the GNU General Public License.
35
//
36
// This exception does not invalidate any other reasons why a work based on
37
// this file might be covered by the GNU General Public License.
38
//
39
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
40
// at http://sources.redhat.com/ecos/ecos-license/
41
// -------------------------------------------
42
//####ECOSGPLCOPYRIGHTEND####
43
//==========================================================================
44
//#####DESCRIPTIONBEGIN####
45
//
46
// Author(s):    jlarmour
47
// Contributors:
48
// Date:         2000-06-12
49
// Purpose:      Memory allocator portion of kernel C API
50
// Description:  This is intentionally only to be included from
51
//               <cyg/kernel/kapi.h>
52
// Usage:        This file should not be used directly - instead it should
53
//               be used via <cyg/kernel/kapi.h>
54
//
55
//
56
//####DESCRIPTIONEND####
57
//
58
//========================================================================*/
59
 
60
/* CONFIGURATION */
61
 
62
#include <pkgconf/memalloc.h>
63
 
64
/* TYPE DEFINITIONS */
65
 
66
struct cyg_mempool_var;
67
typedef struct cyg_mempool_var cyg_mempool_var;
68
 
69
struct cyg_mempool_fix;
70
typedef struct cyg_mempool_fix cyg_mempool_fix;
71
 
72
/*-----------------------------------------------------------------------*/
73
/* Memory pools                                                          */
74
 
75
/* There are two sorts of memory pools.  A variable size memory pool
76
   is for allocating blocks of any size.  A fixed size memory pool, has
77
   the block size specified when the pool is created, and only provides
78
   blocks of that size.  */
79
 
80
/* Create a variable size memory pool */
81
void cyg_mempool_var_create(
82
    void            *base,              /* base of memory to use for pool */
83
    cyg_int32       size,               /* size of memory in bytes        */
84
    cyg_handle_t    *handle,            /* returned handle of memory pool */
85
    cyg_mempool_var *var                /* space to put pool structure in */
86
    );
87
 
88
/* Delete variable size memory pool */
89
void cyg_mempool_var_delete(cyg_handle_t varpool);
90
 
91
#ifdef CYGSEM_MEMALLOC_ALLOCATOR_VARIABLE_THREADAWARE
92
 
93
/* Allocates a block of length size.  This waits if the memory is not
94
   currently available.  */
95
void *cyg_mempool_var_alloc(cyg_handle_t varpool, cyg_int32 size);
96
 
97
# ifdef CYGFUN_KERNEL_THREADS_TIMER
98
 
99
/* Allocates a block of length size.  This waits until abstime,
100
   if the memory is not already available.  NULL is returned if
101
   no memory is available. */
102
void *cyg_mempool_var_timed_alloc(
103
    cyg_handle_t     varpool,
104
    cyg_int32        size,
105
    cyg_tick_count_t abstime);
106
 
107
# endif
108
#endif
109
 
110
/* Allocates a block of length size.  NULL is returned if no memory is
111
   available. */
112
void *cyg_mempool_var_try_alloc(
113
    cyg_handle_t varpool,
114
    cyg_int32    size);
115
 
116
/* Frees memory back into variable size pool. */
117
void cyg_mempool_var_free(cyg_handle_t varpool, void *p);
118
 
119
/* Returns true if there are any threads waiting for memory in the
120
   given memory pool. */
121
cyg_bool_t cyg_mempool_var_waiting(cyg_handle_t varpool);
122
 
123
typedef struct {
124
    cyg_int32 totalmem;
125
    cyg_int32 freemem;
126
    void      *base;
127
    cyg_int32 size;
128
    cyg_int32 blocksize;
129
    cyg_int32 maxfree;                  // The largest free block
130
} cyg_mempool_info;
131
 
132
/* Puts information about a variable memory pool into the structure
133
   provided. */
134
void cyg_mempool_var_get_info(cyg_handle_t varpool, cyg_mempool_info *info);
135
 
136
/* Create a fixed size memory pool */
137
void cyg_mempool_fix_create(
138
    void            *base,              // base of memory to use for pool
139
    cyg_int32       size,               // size of memory in byte
140
    cyg_int32       blocksize,          // size of allocation in bytes
141
    cyg_handle_t    *handle,            // handle of memory pool
142
    cyg_mempool_fix *fix                // space to put pool structure in
143
    );
144
 
145
/* Delete fixed size memory pool */
146
void cyg_mempool_fix_delete(cyg_handle_t fixpool);
147
 
148
#ifdef CYGSEM_MEMALLOC_ALLOCATOR_FIXED_THREADAWARE
149
/* Allocates a block.  This waits if the memory is not
150
   currently available.  */
151
void *cyg_mempool_fix_alloc(cyg_handle_t fixpool);
152
 
153
# ifdef CYGFUN_KERNEL_THREADS_TIMER
154
 
155
/* Allocates a block.  This waits until abstime, if the memory
156
   is not already available.  NULL is returned if no memory is
157
   available. */
158
void *cyg_mempool_fix_timed_alloc(
159
    cyg_handle_t     fixpool,
160
    cyg_tick_count_t abstime);
161
 
162
# endif
163
#endif
164
 
165
/* Allocates a block.  NULL is returned if no memory is available. */
166
void *cyg_mempool_fix_try_alloc(cyg_handle_t fixpool);
167
 
168
/* Frees memory back into fixed size pool. */
169
void cyg_mempool_fix_free(cyg_handle_t fixpool, void *p);
170
 
171
/* Returns true if there are any threads waiting for memory in the
172
   given memory pool. */
173
cyg_bool_t cyg_mempool_fix_waiting(cyg_handle_t fixpool);
174
 
175
/* Puts information about a variable memory pool into the structure
176
   provided. */
177
void cyg_mempool_fix_get_info(cyg_handle_t fixpool, cyg_mempool_info *info);
178
 
179
 
180
 
181
#endif /* ifndef CYGONCE_MEMALLOC_KAPI_H */
182
/* EOF kapi.h */

powered by: WebSVN 2.1.0

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