From b7e575817d692fced1051896f3089ca9d75a5152 Mon Sep 17 00:00:00 2001 From: Bahadir Balban Date: Tue, 3 Nov 2009 15:26:59 +0200 Subject: [PATCH] Merged setup of internal memory caps and container creation The two had common data in their initialization so it only made sense to merge the two. --- src/generic/resource.c | 95 +++++++++++++++++++----------------------- src/glue/arm/init.c | 2 +- 2 files changed, 44 insertions(+), 53 deletions(-) diff --git a/src/generic/resource.c b/src/generic/resource.c index 75bd115..cf85446 100644 --- a/src/generic/resource.c +++ b/src/generic/resource.c @@ -482,53 +482,6 @@ int copy_container_info(struct container *c, struct container_info *cinfo) return 0; } -/* - * Create real containers from compile-time created cinfo structures - */ -void setup_containers(struct boot_resources *bootres, - struct kernel_resources *kres) -{ - struct container *container; - pgd_table_t *current_pgd; - - /* - * Move to real page tables, accounted by - * pgds and pmds provided from the caches - * - * We do not want to delay this too much, - * since we want to avoid allocating an uncertain - * amount of memory from the boot allocators. - */ - current_pgd = realloc_page_tables(); - - /* Move it back - * - * FIXME: Merge until this part of code with - * kres_setup_capabilities and init_system_resources - * it doesn't look good. - */ - cap_list_move(&kres->non_memory_caps, ¤t->cap_list); - - /* Create all containers but leave pagers */ - for (int i = 0; i < bootres->nconts; i++) { - /* Allocate & init container */ - container = container_create(); - - /* Fill in its information */ - copy_container_info(container, &cinfo[i]); - - /* Add it to kernel resources list */ - kres_insert_container(container, kres); - } - - /* Initialize pagers */ - container_init_pagers(kres, current_pgd); - - /* Assign next unused container id for kernel resources */ - kres->cid = id_new(&kres->container_ids); - -} - /* * Copy boot-time allocated kernel capabilities to ones that * are allocated from the capability memcache @@ -565,10 +518,18 @@ void copy_boot_capabilities(struct cap_list *caplist) * Creates capabilities allocated with a real id, and from the * capability cache, in place of ones allocated at boot-time. */ -void kernel_setup_capabilities(struct boot_resources *bootres, - struct kernel_resources *kres) +void setup_kernel_resources(struct boot_resources *bootres, + struct kernel_resources *kres) { struct capability *cap; + struct container *container; + pgd_table_t *current_pgd; + + /* + * See how many containers we have. Assign next + * unused container id for kernel resources + */ + kres->cid = id_get(&kres->container_ids, bootres->nconts + 1); /* First initialize the list of non-memory capabilities */ cap = boot_capability_create(); @@ -599,6 +560,38 @@ void kernel_setup_capabilities(struct boot_resources *bootres, copy_boot_capabilities(&kres->virtmem_free); copy_boot_capabilities(&kres->devmem_used); copy_boot_capabilities(&kres->devmem_free); + + /* + * Move to real page tables, accounted by + * pgds and pmds provided from the caches + * + * We do not want to delay this too much, + * since we want to avoid allocating an uncertain + * amount of memory from the boot allocators. + */ + current_pgd = realloc_page_tables(); + + /* Move it back */ + cap_list_move(&kres->non_memory_caps, ¤t->cap_list); + + /* + * Create real containers from compile-time created + * cinfo structures + */ + for (int i = 0; i < bootres->nconts; i++) { + /* Allocate & init container */ + container = container_create(); + + /* Fill in its information */ + copy_container_info(container, &cinfo[i]); + + /* Add it to kernel resources list */ + kres_insert_container(container, kres); + } + + /* Initialize pagers */ + container_init_pagers(kres, current_pgd); + } /* @@ -867,9 +860,7 @@ int init_system_resources(struct kernel_resources *kres) init_resource_allocators(&bootres, kres); - kernel_setup_capabilities(&bootres, kres); - - setup_containers(&bootres, kres); + setup_kernel_resources(&bootres, kres); return 0; } diff --git a/src/glue/arm/init.c b/src/glue/arm/init.c index bf4b7a8..1fce6af 100644 --- a/src/glue/arm/init.c +++ b/src/glue/arm/init.c @@ -279,7 +279,7 @@ void init_finalize(struct kernel_resources *kres) free_boot_memory(&kernel_resources); /* - * Set up KIP UTCB ref + * Set up initial KIP UTCB ref */ kip.utcb = (u32)current->utcb_address;