Palacios Public Git Repository

To checkout Palacios execute

  git clone http://v3vee.org/palacios/palacios.web/palacios.git
This will give you the master branch. You probably want the devel branch or one of the release branches. To switch to the devel branch, simply execute
  cd palacios
  git checkout --track -b devel origin/devel
The other branches are similar.


moved host OS interfaces to a separate directory palacios/src/interfaces and palacios...
[palacios.git] / geekos / src / geekos / malloc.c
1 /*
2  * GeekOS memory allocation API
3  * Copyright (c) 2001, David H. Hovemeyer <daveho@cs.umd.edu>
4  * $Revision: 1.1 $
5  * 
6  * This is free software.  You are permitted to use,
7  * redistribute, and modify it as specified in the file "COPYING".
8  */
9
10 #include <geekos/screen.h>
11 #include <geekos/int.h>
12 #include <geekos/bget.h>
13 #include <geekos/kassert.h>
14 #include <geekos/malloc.h>
15
16 /*
17  * Initialize the heap starting at given address and occupying
18  * specified number of bytes.
19  */
20 void Init_Heap(ulong_t start, ulong_t size)
21 {
22     /*Print("Creating kernel heap: start=%lx, size=%ld\n", start, size);*/
23     bpool((void*) start, size);
24 }
25
26 /*
27  * Dynamically allocate a buffer of given size.
28  * Returns null if there is not enough memory to satisfy the
29  * allocation.
30  */
31 void* Malloc(ulong_t size)
32 {
33     void *result;
34     bool iflag;
35
36     KASSERT(size > 0);
37
38     iflag = Begin_Int_Atomic();
39     result = bget(size);
40     End_Int_Atomic(iflag);
41
42     return result;
43 }
44
45 /*
46  * Free a buffer allocated with Malloc() or Malloc().
47  */
48 void Free(void* buf)
49 {
50     bool iflag;
51
52     iflag = Begin_Int_Atomic();
53     brel(buf);
54     End_Int_Atomic(iflag);
55 }