]> rtime.felk.cvut.cz Git - l4.git/blob - kernel/fiasco/src/kern/ppc32/kmem_alloc-ppc32.cpp
update
[l4.git] / kernel / fiasco / src / kern / ppc32 / kmem_alloc-ppc32.cpp
1 //----------------------------------------------------------------------------
2 IMPLEMENTATION [ppc32]:
3
4 #include "mem_region.h"
5 IMPLEMENT
6 Kmem_alloc::Kmem_alloc()
7 {
8   Mword alloc_size = Config::Kmem_size;
9   unsigned long max = ~0UL;
10 #warning This code needs adaption (see e.g. the arm version)
11   for (;;)
12     {
13       Mem_region r; r.start=3; r.end=1; // = Kip::k()->last_free(max);
14
15       if (r.start > r.end + 1)
16         panic("Corrupt memory descscriptor in KIP...");
17
18       if (r.start == r.end + 1)
19         panic("Could not acquire enough kernel memory");
20
21       max = r.start;
22       Mword size = r.end - r.start + 1;
23       if(alloc_size <= size)
24         {
25           r.start += (size - alloc_size);
26           Kip::k()->add_mem_region(Mem_desc(r.start, r.end,
27                                             Mem_desc::Reserved));
28
29           /* init buddy allocator with physical addresses */
30           a->init(r.start);
31           a->add_mem((void*)r.start, alloc_size);
32           printf("Buddy allocator at: [%08lx; %08lx] - %lu KB\n", 
33                  r.start, r.end, alloc_size / 1024);
34           break;
35         }
36     }
37 }
38
39 PUBLIC inline //NEEDS["kmem_space.h"]
40 Address
41 Kmem_alloc::to_phys(void *v) const
42 {
43   (void)v;
44   //return Kmem_space::kdir()->virt_to_phys((Address)v);
45   return ~0UL;
46 }
47
48 //----------------------------------------------------------------------------
49 IMPLEMENTATION [ppc32 && debug]:
50
51 #include <cstdio>
52
53 #include "kip_init.h"
54 #include "panic.h"
55
56 PUBLIC
57 void Kmem_alloc::debug_dump()
58 {
59   a->dump();
60 }