1 //----------------------------------------------------------------------------
2 IMPLEMENTATION [sparc]:
4 #include "mem_region.h"
7 Kmem_alloc::Kmem_alloc()
9 Mword alloc_size = Config::Kmem_size;
10 a->init(Mem_layout::Map_base);
12 /* First, collect non-used physical memory chunks
14 Mem_region_map<64> map;
15 unsigned long avail_size = create_free_map(Kip::k(), &map);
16 printf("Available phys mem: %08lx\n", avail_size);
18 for (int i = map.length() - 1; i >= 0 && alloc_size > 0; --i)
20 Mem_region f = map[i];
21 if (f.size() > alloc_size)
22 f.start += (f.size() - alloc_size);
24 printf(" [%08lx - %08lx %4ld kB]\n", f.start, f.end, f.size() >> 10);
25 Kip::k()->add_mem_region(Mem_desc(f.start, f.end,
27 printf(" -> %08lx\n", Mem_layout::phys_to_pmem(f.start));
28 a->add_mem((void*)Mem_layout::phys_to_pmem(f.start), f.size());
29 alloc_size -= f.size();