mirror of
https://github.com/drasko/codezero.git
synced 2026-01-16 04:43:16 +01:00
Put cinfo array into initdata section. Added more precision in bootmem
cinfo array is now freed along with other init memory. bootmem allocator memory is reduced to be completely used up. free boot memory now prints the used free memory as well.
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
Import('env')
|
||||
|
||||
# The set of source files associated with this SConscript file.
|
||||
src_local = ['irq.c', 'scheduler.c', 'time.c', 'tcb.c', 'space.c', 'bootm.c', 'resource.c', 'container.c', 'capability.c', 'cinfo.c']
|
||||
src_local = ['irq.c', 'scheduler.c', 'time.c', 'tcb.c', 'space.c', 'bootmem.c', 'resource.c', 'container.c', 'capability.c', 'cinfo.c']
|
||||
|
||||
obj = env.Object(src_local)
|
||||
Return('obj')
|
||||
|
||||
@@ -10,16 +10,23 @@
|
||||
#include <l4/lib/printk.h>
|
||||
#include <l4/generic/space.h>
|
||||
|
||||
/* All memory allocated here is discarded after boot */
|
||||
|
||||
#define BOOTMEM_SIZE SZ_32K
|
||||
/*
|
||||
* All memory allocated here is discarded after boot.
|
||||
* Increase this size if bootmem allocations fail.
|
||||
*/
|
||||
#define BOOTMEM_SIZE (SZ_4K * 4)
|
||||
|
||||
SECTION(".init.pgd") pgd_table_t init_pgd;
|
||||
SECTION(".init.bootmem") char bootmem[BOOTMEM_SIZE];
|
||||
SECTION(".init.data") struct address_space init_space;
|
||||
__initdata struct address_space init_space;
|
||||
|
||||
static unsigned long cursor = (unsigned long)&bootmem;
|
||||
|
||||
unsigned long bootmem_free_pages(void)
|
||||
{
|
||||
return BOOTMEM_SIZE - (page_align_up(cursor) - (unsigned long)&bootmem);
|
||||
}
|
||||
|
||||
void *alloc_bootmem(int size, int alignment)
|
||||
{
|
||||
void *ptr;
|
||||
@@ -335,6 +335,7 @@ int free_boot_memory(struct kernel_resources *kres)
|
||||
__pfn(virt_to_phys(_start_init));
|
||||
unsigned long pfn_end =
|
||||
__pfn(page_align_up(virt_to_phys(_end_init)));
|
||||
unsigned long init_pfns = pfn_end - pfn_start;
|
||||
|
||||
/* Trim kernel used memory cap */
|
||||
memcap_unmap(0, &kres->physmem_used, pfn_start, pfn_end);
|
||||
@@ -350,9 +351,9 @@ int free_boot_memory(struct kernel_resources *kres)
|
||||
list_foreach_struct(c, &kres->containers.list, list)
|
||||
c->pager = 0;
|
||||
|
||||
printk("%s: Freed %lu KB init memory.\n",
|
||||
__KERNELNAME__,
|
||||
__pfn_to_addr((pfn_end - pfn_start)) / 1024);
|
||||
printk("%s: Freed %lu KB init memory, of which %lu KB was used.\n",
|
||||
__KERNELNAME__, init_pfns * 4,
|
||||
(init_pfns - __pfn(page_align_up(bootmem_free_pages()))) * 4);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user