Xenomai  3.0.5
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_free(struct cobalt_umm *umm, void *p)
36 {
37  xnheap_free(&umm->heap, p);
38 }
39 
40 static inline
41 __u32 cobalt_umm_offset(struct cobalt_umm *umm, void *p)
42 {
43  return p - xnheap_get_membase(&umm->heap);
44 }
45 
46 int cobalt_memdev_init(void);
47 
48 void cobalt_memdev_cleanup(void);
49 
50 int cobalt_umm_init(struct cobalt_umm *umm, u32 size,
51  void (*release)(struct cobalt_umm *umm));
52 
53 void cobalt_umm_destroy(struct cobalt_umm *umm);
54 
55 #endif /* !_COBALT_POSIX_MEMORY_H */
void xnheap_free(struct xnheap *heap, void *block)
Release a block to a memory heap.
Definition: heap.c:492
void * xnheap_alloc(struct xnheap *heap, u32 size)
Allocate a memory block from a memory heap.
Definition: heap.c:406