1
/*
2
* \brief Memory subsystem
3
* \author Christian Helmuth
4
* \date 2008-08-15
5
*/
6
7
/*
8
* Copyright (C) 2008-2013 Genode Labs GmbH
9
*
10
* This file is part of the Genode OS framework, which is distributed
11
* under the terms of the GNU General Public License version 2.
12
*/
13
14
#
ifndef _INCLUDE__DDE_KIT__MEMORY_H_
15
#
define _INCLUDE__DDE_KIT__MEMORY_H_
16
17
#
include <dde_kit/types.h>
18
19
20
/*******************
21
** Slab facility **
22
*******************/
23
24
struct
dde_kit_slab;
25
26
/**
27
* Store user pointer in slab cache
28
*
29
* \param slab pointer to slab cache
30
* \param data user pointer
31
*/
32
void
dde_kit_slab_set_data(
struct
dde_kit_slab *
slab
,
void *
data
)
;
33
34
/**
35
* Read user pointer from slab cache
36
*
37
* \param slab pointer to slab cache
38
*
39
* \return stored user pointer or 0
40
*/
41
void *
dde_kit_slab_get_data(
struct
dde_kit_slab *
slab
)
;
42
43
/**
44
* Allocate slab in slab cache
45
*
46
* \param slab pointer to slab cache
47
*
48
* \return pointer to allocated slab
49
*/
50
void *
dde_kit_slab_alloc(
struct
dde_kit_slab *
slab
)
;
51
52
/**
53
* Deallocate slab in slab cache
54
*
55
* \param slab pointer to slab cache
56
* \param objp pointer to allocated slab
57
*/
58
void
dde_kit_slab_free(
struct
dde_kit_slab *
slab
,
void *
objp
)
;
59
60
/**
61
* Destroy slab cache
62
*
63
* \param slab pointer to slab cache structure
64
*/
65
void
dde_kit_slab_destroy(
struct
dde_kit_slab *
slab
)
;
66
67
/**
68
* Initialize slab cache
69
*
70
* \param size size of cache objects
71
*
72
* \return pointer to new slab cache or 0 on error
73
*
74
* Allocated blocks have valid virt->phys mappings and are physically
75
* contiguous.
76
*/
77
struct
dde_kit_slab *
dde_kit_slab_init(
unsigned
size)
;
78
79
80
/**********************************
81
** Large-block memory allocator **
82
**********************************/
83
84
/**
85
* Allocate large memory block
86
*
87
* \param size block size
88
*
89
* \return pointer to new memory block
90
*
91
* Allocations via this allocator may be slow (because RPCs to remote services
92
* may be involved) and should be used only for large blocks of several pages.
93
* If allocations/deallocations are relatively dynamic the large memory
94
* allocator should be used as backend for a block caching frontend.
95
*
96
* Allocated blocks have valid virt->phys mappings and are physically
97
* contiguous.
98
*/
99
void *
dde_kit_large_malloc(
dde_kit_size_t
size
)
;
100
101
/**
102
* Free large memory block
103
*
104
* \param p pointer to memory block
105
*/
106
void
dde_kit_large_free(
void *
p
)
;
107
108
109
/*****************************
110
** Simple memory allocator **
111
*****************************/
112
113
/**
114
* Allocate memory block via simple allocator
115
*
116
* \param size block size
117
*
118
* \return pointer to new memory block
119
*
120
* The blocks allocated via this allocator CANNOT be used for DMA or other
121
* device operations, i.e., there exists no virt->phys mapping.
122
*/
123
void *
dde_kit_simple_malloc(
dde_kit_size_t
size
)
;
124
125
/**
126
* Free memory block via simple allocator
127
*
128
* \param p pointer to memory block
129
*
130
* As in C99, if `p` is NULL no operation is performed.
131
*/
132
void
dde_kit_simple_free(
void *
p
)
;
133
134
#
endif /* _INCLUDE__DDE_KIT__MEMORY_H_ */