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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [services/] [memalloc/] [common/] [current/] [include/] [kapi.h] - 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_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 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):    jlarmour
46
// Contributors:
47
// Date:         2000-06-12
48
// Purpose:      Memory allocator portion of kernel C API
49
// Description:  This is intentionally only to be included from
50
//               <cyg/kernel/kapi.h>
51
// Usage:        This file should not be used directly - instead it should
52
//               be used via <cyg/kernel/kapi.h>
53
//
54
//
55
//####DESCRIPTIONEND####
56
//
57
//========================================================================*/
58
 
59
/* CONFIGURATION */
60
#include <pkgconf/system.h>
61
#include <pkgconf/memalloc.h>
62
 
63
/* TYPE DEFINITIONS */
64
#ifdef CYGPKG_KERNEL
65
#include <cyg/kernel/kapi.h>
66
#else
67
typedef cyg_uint32 cyg_handle_t;
68
#endif
69
 
70
/*---------------------------------------------------------------------------*/
71
 
72
#ifdef __cplusplus
73
extern "C" {
74
#endif
75
 
76
/*---------------------------------------------------------------------------*/
77
struct cyg_mempool_var;
78
typedef struct cyg_mempool_var cyg_mempool_var;
79
 
80
struct cyg_mempool_fix;
81
typedef struct cyg_mempool_fix cyg_mempool_fix;
82
 
83
/*-----------------------------------------------------------------------*/
84
/* Memory pools                                                          */
85
 
86
/* There are two sorts of memory pools.  A variable size memory pool
87
   is for allocating blocks of any size.  A fixed size memory pool, has
88
   the block size specified when the pool is created, and only provides
89
   blocks of that size.  */
90
 
91
/* Create a variable size memory pool */
92
void cyg_mempool_var_create(
93
    void            *base,              /* base of memory to use for pool */
94
    cyg_int32       size,               /* size of memory in bytes        */
95
    cyg_handle_t    *handle,            /* returned handle of memory pool */
96
    cyg_mempool_var *var                /* space to put pool structure in */
97
    ) __THROW;
98
 
99
/* Delete variable size memory pool */
100
void cyg_mempool_var_delete(cyg_handle_t varpool) __THROW;
101
 
102
#ifdef CYGSEM_MEMALLOC_ALLOCATOR_VARIABLE_THREADAWARE
103
 
104
/* Allocates a block of length size.  This waits if the memory is not
105
   currently available.  */
106
void *cyg_mempool_var_alloc(cyg_handle_t varpool, cyg_int32 size) __THROW;
107
 
108
# ifdef CYGFUN_KERNEL_THREADS_TIMER
109
 
110
/* Allocates a block of length size.  This waits until abstime,
111
   if the memory is not already available.  NULL is returned if
112
   no memory is available. */
113
void *cyg_mempool_var_timed_alloc(
114
    cyg_handle_t     varpool,
115
    cyg_int32        size,
116
    cyg_tick_count_t abstime) __THROW;
117
 
118
# endif
119
#endif
120
 
121
/* Allocates a block of length size.  NULL is returned if no memory is
122
   available. */
123
void *cyg_mempool_var_try_alloc(
124
    cyg_handle_t varpool,
125
    cyg_int32    size) __THROW;
126
 
127
/* Frees memory back into variable size pool. */
128
void cyg_mempool_var_free(cyg_handle_t varpool, void *p) __THROW;
129
 
130
/* Returns true if there are any threads waiting for memory in the
131
   given memory pool. */
132
cyg_bool_t cyg_mempool_var_waiting(cyg_handle_t varpool) __THROW;
133
 
134
typedef struct {
135
    cyg_int32 totalmem;
136
    cyg_int32 freemem;
137
    void      *base;
138
    cyg_int32 size;
139
    cyg_int32 blocksize;
140
    cyg_int32 maxfree;                  // The largest free block
141
} cyg_mempool_info;
142
 
143
/* Puts information about a variable memory pool into the structure
144
   provided. */
145
void cyg_mempool_var_get_info(cyg_handle_t varpool, cyg_mempool_info *info) __THROW;
146
 
147
/* Create a fixed size memory pool */
148
void cyg_mempool_fix_create(
149
    void            *base,              // base of memory to use for pool
150
    cyg_int32       size,               // size of memory in byte
151
    cyg_int32       blocksize,          // size of allocation in bytes
152
    cyg_handle_t    *handle,            // handle of memory pool
153
    cyg_mempool_fix *fix                // space to put pool structure in
154
    ) __THROW;
155
 
156
/* Delete fixed size memory pool */
157
void cyg_mempool_fix_delete(cyg_handle_t fixpool) __THROW;
158
 
159
#ifdef CYGSEM_MEMALLOC_ALLOCATOR_FIXED_THREADAWARE
160
/* Allocates a block.  This waits if the memory is not
161
   currently available.  */
162
void *cyg_mempool_fix_alloc(cyg_handle_t fixpool) __THROW;
163
 
164
# ifdef CYGFUN_KERNEL_THREADS_TIMER
165
 
166
/* Allocates a block.  This waits until abstime, if the memory
167
   is not already available.  NULL is returned if no memory is
168
   available. */
169
void *cyg_mempool_fix_timed_alloc(
170
    cyg_handle_t     fixpool,
171
    cyg_tick_count_t abstime) __THROW;
172
 
173
# endif
174
#endif
175
 
176
/* Allocates a block.  NULL is returned if no memory is available. */
177
void *cyg_mempool_fix_try_alloc(cyg_handle_t fixpool) __THROW;
178
 
179
/* Frees memory back into fixed size pool. */
180
void cyg_mempool_fix_free(cyg_handle_t fixpool, void *p) __THROW;
181
 
182
/* Returns true if there are any threads waiting for memory in the
183
   given memory pool. */
184
cyg_bool_t cyg_mempool_fix_waiting(cyg_handle_t fixpool) __THROW;
185
 
186
/* Puts information about a variable memory pool into the structure
187
   provided. */
188
void cyg_mempool_fix_get_info(cyg_handle_t fixpool, cyg_mempool_info *info) __THROW;
189
 
190
/* user overrideable function invoked before running out of memory. */
191
__externC void cyg_memalloc_alloc_fail(char * file, int line, cyg_int32 size)
192
     __THROW;
193
 
194
/*---------------------------------------------------------------------------*/
195
#ifdef __cplusplus
196
}
197
#endif
198
 
199
/*---------------------------------------------------------------------------*/
200
 
201
 
202
#endif /* ifndef CYGONCE_MEMALLOC_KAPI_H */
203
/* EOF kapi.h */

powered by: WebSVN 2.1.0

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