Xenomai  3.1
memory.h
1 /*
2  * This file is part of the Xenomai project.
3  *
4  * Copyright (C) 2014 Philippe Gerum <rpm@xenomai.org>
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License as
8  * published by the Free Software Foundation; either version 2 of the
9  * License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19  */
20 #ifndef _COBALT_POSIX_MEMORY_H
21 #define _COBALT_POSIX_MEMORY_H
22 
23 #include <cobalt/kernel/ppd.h>
24 
25 #define cobalt_umm_set_name(__umm, __fmt, __args...) \
26  xnheap_set_name(&(__umm)->heap, (__fmt), ## __args)
27 
28 static inline
29 void *cobalt_umm_alloc(struct cobalt_umm *umm, __u32 size)
30 {
31  return xnheap_alloc(&umm->heap, size);
32 }
33 
34 static inline
35 void *cobalt_umm_zalloc(struct cobalt_umm *umm, __u32 size)
36 {
37  return xnheap_zalloc(&umm->heap, size);
38 }
39 
40 static inline
41 void cobalt_umm_free(struct cobalt_umm *umm, void *p)
42 {
43  xnheap_free(&umm->heap, p);
44 }
45 
46 static inline
47 __u32 cobalt_umm_offset(struct cobalt_umm *umm, void *p)
48 {
49  return p - xnheap_get_membase(&umm->heap);
50 }
51 
52 int cobalt_memdev_init(void);
53 
54 void cobalt_memdev_cleanup(void);
55 
56 int cobalt_umm_init(struct cobalt_umm *umm, u32 size,
57  void (*release)(struct cobalt_umm *umm));
58 
59 void cobalt_umm_destroy(struct cobalt_umm *umm);
60 
61 #endif /* !_COBALT_POSIX_MEMORY_H */
void xnheap_free(struct xnheap *heap, void *block)
Release a block to a memory heap.
Definition: heap.c:618
void * xnheap_alloc(struct xnheap *heap, size_t size)
Allocate a memory block from a memory heap.
Definition: heap.c:531