]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/l4re-core/moe/server/src/mem.cc
Update
[l4.git] / l4 / pkg / l4re-core / moe / server / src / mem.cc
1 /*
2  * (c) 2008-2009 Adam Lackorzynski <adam@os.inf.tu-dresden.de>,
3  *               Alexander Warg <warg@os.inf.tu-dresden.de>
4  *     economic rights: Technische Universität Dresden (Germany)
5  *
6  * This file is part of TUD:OS and distributed under the terms of the
7  * GNU General Public License 2.
8  * Please see the COPYING-GPL-2 file for details.
9  */
10 #define _GNU_SOURCE 1
11 #include <bits/l4-malloc.h>
12 #include <sys/mman.h>
13 #include <errno.h>
14
15 #include "page_alloc.h"
16
17 #include <l4/sys/types.h>
18
19 #include <l4/cxx/iostream>
20
21 static void *current_morecore_end;
22
23 void *uclibc_morecore(long bytes)
24 {
25   // Calling morecore with 0 size is done by the malloc/free implementation
26   // to check for the amount of memory it got from the last call to
27   // morecore.
28   // With a negative value, 'free' wants to return memory, we do not support
29   // that here.
30   if (bytes <= 0)
31     return current_morecore_end;
32
33   size_t s = l4_round_page(bytes);
34   void *b = Single_page_alloc_base::_alloc(Single_page_alloc_base::nothrow,
35                                            s, L4_PAGESIZE);
36   if (L4_UNLIKELY(!b))
37     return MAP_FAILED;
38
39   current_morecore_end = static_cast<char *>(b) + s;
40   return b;
41 }
42
43 void * mmap(void * /*start*/, size_t /*length*/, int /*prot*/, int /*flags*/, int /*fd*/, off_t /*offset*/) throw()
44 {
45   L4::cout << "mmap() called: unimplemented!\n";
46   errno = EINVAL;
47   return MAP_FAILED;
48 }
49
50 int munmap(void * /*start*/, size_t  /*length*/) throw()
51 {
52   L4::cout << "munmap() called: unimplemented!\n";
53   errno = EINVAL;
54   return -1;
55 }
56
57 void * mremap(void * /*old_address*/, size_t /*old_size*/, size_t /*new_size*/,
58               int /*may_move*/, ...) throw()
59 {
60   L4::cout << "mremap() called: unimplemented!\n";
61   errno = EINVAL;
62   return MAP_FAILED;
63 }