mirror of
https://github.com/drasko/codezero.git
synced 2026-02-28 17:53:13 +01:00
Coding style changes in kernel startup
This commit is contained in:
@@ -24,9 +24,9 @@ int container_init(struct container *c)
|
|||||||
init_mutex_queue_head(&c->mutex_queue_head);
|
init_mutex_queue_head(&c->mutex_queue_head);
|
||||||
|
|
||||||
/* Ini pager structs */
|
/* Ini pager structs */
|
||||||
for (int i = 0; i < CONFIG_MAX_PAGERS_USED; i++) {
|
for (int i = 0; i < CONFIG_MAX_PAGERS_USED; i++)
|
||||||
cap_list_init(&c->pager[i].cap_list);
|
cap_list_init(&c->pager[i].cap_list);
|
||||||
}
|
|
||||||
/* Init scheduler */
|
/* Init scheduler */
|
||||||
sched_init(&c->scheduler);
|
sched_init(&c->scheduler);
|
||||||
|
|
||||||
@@ -207,6 +207,8 @@ int init_pager(struct pager *pager, struct container *cont)
|
|||||||
/*
|
/*
|
||||||
* Initialize dummy current capability list pointer
|
* Initialize dummy current capability list pointer
|
||||||
* so that capability accounting can be done as normal
|
* so that capability accounting can be done as normal
|
||||||
|
* FYI: We're still on bootstack instead of current's
|
||||||
|
* real stack. Hence this is a dummy.
|
||||||
*/
|
*/
|
||||||
current->cap_list_ptr = &pager->cap_list;
|
current->cap_list_ptr = &pager->cap_list;
|
||||||
|
|
||||||
|
|||||||
@@ -471,6 +471,7 @@ int copy_container_info(struct container *c, struct container_info *cinfo)
|
|||||||
/* Copy capabilities */
|
/* Copy capabilities */
|
||||||
for (int i = 0; i < c->npagers; i++)
|
for (int i = 0; i < c->npagers; i++)
|
||||||
copy_pager_info(&c->pager[i], &cinfo->pager[i]);
|
copy_pager_info(&c->pager[i], &cinfo->pager[i]);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -663,8 +664,9 @@ void init_resource_allocators(struct boot_resources *bootres,
|
|||||||
bootres->nkpgds++;
|
bootres->nkpgds++;
|
||||||
|
|
||||||
/* Initialise PGD cache */
|
/* Initialise PGD cache */
|
||||||
kcont->pgd_cache = init_resource_cache(bootres->nspaces,
|
kcont->pgd_cache =
|
||||||
PGD_SIZE, kcont, 1);
|
init_resource_cache(bootres->nspaces,
|
||||||
|
PGD_SIZE, kcont, 1);
|
||||||
|
|
||||||
/* Initialise struct address_space cache */
|
/* Initialise struct address_space cache */
|
||||||
kcont->space_cache =
|
kcont->space_cache =
|
||||||
@@ -673,22 +675,26 @@ void init_resource_allocators(struct boot_resources *bootres,
|
|||||||
kcont, 0);
|
kcont, 0);
|
||||||
|
|
||||||
/* Initialise ktcb cache */
|
/* Initialise ktcb cache */
|
||||||
kcont->ktcb_cache = init_resource_cache(bootres->nthreads,
|
kcont->ktcb_cache =
|
||||||
PAGE_SIZE, kcont, 1);
|
init_resource_cache(bootres->nthreads,
|
||||||
|
PAGE_SIZE, kcont, 1);
|
||||||
|
|
||||||
/* Initialise umutex cache */
|
/* Initialise umutex cache */
|
||||||
kcont->mutex_cache = init_resource_cache(bootres->nmutex,
|
kcont->mutex_cache =
|
||||||
sizeof(struct mutex_queue),
|
init_resource_cache(bootres->nmutex,
|
||||||
kcont, 0);
|
sizeof(struct mutex_queue),
|
||||||
|
kcont, 0);
|
||||||
/* Initialise container cache */
|
/* Initialise container cache */
|
||||||
kcont->cont_cache = init_resource_cache(bootres->nconts,
|
kcont->cont_cache =
|
||||||
sizeof(struct container),
|
init_resource_cache(bootres->nconts,
|
||||||
kcont, 0);
|
sizeof(struct container),
|
||||||
|
kcont, 0);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Add all caps used by the kernel
|
* Add all caps used by the kernel
|
||||||
* Two extra in case more memcaps get split after cap cache init below.
|
* Two extra in case more memcaps get split after
|
||||||
* Three extra for quantitative kernel caps for pmds, pgds, caps.
|
* cap cache init below. Three extra for quantitative
|
||||||
|
* kernel caps for pmds, pgds, caps.
|
||||||
*/
|
*/
|
||||||
bootres->nkcaps += kcont->virtmem_used.ncaps +
|
bootres->nkcaps += kcont->virtmem_used.ncaps +
|
||||||
kcont->virtmem_free.ncaps +
|
kcont->virtmem_free.ncaps +
|
||||||
@@ -699,9 +705,10 @@ void init_resource_allocators(struct boot_resources *bootres,
|
|||||||
bootres->ncaps += bootres->nkcaps;
|
bootres->ncaps += bootres->nkcaps;
|
||||||
|
|
||||||
/* Initialise capability cache */
|
/* Initialise capability cache */
|
||||||
kcont->cap_cache = init_resource_cache(bootres->ncaps,
|
kcont->cap_cache =
|
||||||
sizeof(struct capability),
|
init_resource_cache(bootres->ncaps,
|
||||||
kcont, 0);
|
sizeof(struct capability),
|
||||||
|
kcont, 0);
|
||||||
|
|
||||||
/* Count boot pmds used so far and add them */
|
/* Count boot pmds used so far and add them */
|
||||||
bootres->nkpmds += pgd_count_pmds(&init_pgd);
|
bootres->nkpmds += pgd_count_pmds(&init_pgd);
|
||||||
@@ -712,15 +719,17 @@ void init_resource_allocators(struct boot_resources *bootres,
|
|||||||
* cache init and add them.
|
* cache init and add them.
|
||||||
*/
|
*/
|
||||||
bootres->nkpmds += ((bootres->npmds * PMD_SIZE) / PMD_MAP_SIZE);
|
bootres->nkpmds += ((bootres->npmds * PMD_SIZE) / PMD_MAP_SIZE);
|
||||||
if (!is_aligned(bootres->npmds * PMD_SIZE, PMD_MAP_SIZE))
|
if (!is_aligned(bootres->npmds * PMD_SIZE,
|
||||||
|
PMD_MAP_SIZE))
|
||||||
bootres->nkpmds++;
|
bootres->nkpmds++;
|
||||||
|
|
||||||
/* Add kernel pmds to all pmd count */
|
/* Add kernel pmds to all pmd count */
|
||||||
bootres->npmds += bootres->nkpmds;
|
bootres->npmds += bootres->nkpmds;
|
||||||
|
|
||||||
/* Initialise PMD cache */
|
/* Initialise PMD cache */
|
||||||
kcont->pmd_cache = init_resource_cache(bootres->npmds,
|
kcont->pmd_cache =
|
||||||
PMD_SIZE, kcont, 1);
|
init_resource_cache(bootres->npmds,
|
||||||
|
PMD_SIZE, kcont, 1);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -740,16 +749,20 @@ int process_cap_info(struct cap_info *cap,
|
|||||||
case CAP_RTYPE_THREADPOOL:
|
case CAP_RTYPE_THREADPOOL:
|
||||||
bootres->nthreads += cap->size;
|
bootres->nthreads += cap->size;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CAP_RTYPE_SPACEPOOL:
|
case CAP_RTYPE_SPACEPOOL:
|
||||||
bootres->nspaces += cap->size;
|
bootres->nspaces += cap->size;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CAP_RTYPE_MUTEXPOOL:
|
case CAP_RTYPE_MUTEXPOOL:
|
||||||
bootres->nmutex += cap->size;
|
bootres->nmutex += cap->size;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CAP_RTYPE_MAPPOOL:
|
case CAP_RTYPE_MAPPOOL:
|
||||||
/* Speficies how many pmds can be mapped */
|
/* Speficies how many pmds can be mapped */
|
||||||
bootres->npmds += cap->size;
|
bootres->npmds += cap->size;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CAP_RTYPE_CAPPOOL:
|
case CAP_RTYPE_CAPPOOL:
|
||||||
/* Specifies how many new caps can be created */
|
/* Specifies how many new caps can be created */
|
||||||
bootres->ncaps += cap->size;
|
bootres->ncaps += cap->size;
|
||||||
@@ -772,6 +785,7 @@ int process_cap_info(struct cap_info *cap,
|
|||||||
BUG();
|
BUG();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CAP_RTYPE_PHYSMEM:
|
case CAP_RTYPE_PHYSMEM:
|
||||||
if ((ret = memcap_unmap(&kcont->physmem_free,
|
if ((ret = memcap_unmap(&kcont->physmem_free,
|
||||||
cap->start, cap->end))) {
|
cap->start, cap->end))) {
|
||||||
@@ -790,6 +804,7 @@ int process_cap_info(struct cap_info *cap,
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user