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:
Bahadir Balban
2009-11-21 13:35:53 +02:00
parent 5bff5b5fbf
commit caa7ac0764
6 changed files with 20 additions and 9 deletions

View File

@@ -5,6 +5,7 @@
#ifndef __BOOTMEM_H__
#define __BOOTMEM_H__
unsigned long bootmem_free_pages(void);
void *alloc_bootmem(int size, int alignment);
pmd_table_t *alloc_boot_pmd(void);

View File

@@ -17,6 +17,8 @@
#define INC_API(x) <l4/api/x>
#define INC_GLUE(x) <l4/glue/__ARCH__/x>
#define __initdata SECTION(".init.data")
/* use this to place code/data in a certain section */
#define SECTION(x) __attribute__((section(x)))
#define ALIGN(x) __attribute__((aligned (x)))

View File

@@ -37,7 +37,7 @@ cinfo_file_start = \
* Add irqs, exceptions
*/
struct container_info cinfo[] = {
__initdata struct container_info cinfo[] = {
'''
cinfo_file_end = \
'''

View File

@@ -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')

View File

@@ -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;

View File

@@ -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;
}