mirror of
https://github.com/drasko/codezero.git
synced 2026-04-17 17:29:04 +02:00
Cleaned up pager initialization code.
This commit is contained in:
@@ -11,3 +11,5 @@ MM0 TODO List:
|
|||||||
with those regions.
|
with those regions.
|
||||||
5.) read_file_pages()/write_file_pages() needs to be tested and improved in
|
5.) read_file_pages()/write_file_pages() needs to be tested and improved in
|
||||||
terms of syscalls to microkernel.
|
terms of syscalls to microkernel.
|
||||||
|
|
||||||
|
(1,3,4) Done.
|
||||||
|
|||||||
@@ -97,7 +97,8 @@ int mm0_task_init(struct vm_file *f, unsigned long task_start,
|
|||||||
task->spid = ids->spid;
|
task->spid = ids->spid;
|
||||||
task->tgid = ids->tgid;
|
task->tgid = ids->tgid;
|
||||||
|
|
||||||
if ((err = boottask_setup_regions(f, task, task_start, task_end)) < 0)
|
if ((err = boottask_setup_regions(f, task,
|
||||||
|
task_start, task_end)) < 0)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
if ((err = boottask_mmap_regions(task, f)) < 0)
|
if ((err = boottask_mmap_regions(task, f)) < 0)
|
||||||
@@ -115,7 +116,8 @@ int mm0_task_init(struct vm_file *f, unsigned long task_start,
|
|||||||
BUG_ON(task->utcb_address != UTCB_AREA_START);
|
BUG_ON(task->utcb_address != UTCB_AREA_START);
|
||||||
|
|
||||||
/* Pager must prefault its utcb */
|
/* Pager must prefault its utcb */
|
||||||
prefault_page(task, task->utcb_address, VM_READ | VM_WRITE);
|
prefault_page(task, task->utcb_address,
|
||||||
|
VM_READ | VM_WRITE);
|
||||||
|
|
||||||
/* Add the task to the global task list */
|
/* Add the task to the global task list */
|
||||||
global_add_task(task);
|
global_add_task(task);
|
||||||
@@ -129,8 +131,9 @@ int mm0_task_init(struct vm_file *f, unsigned long task_start,
|
|||||||
struct vm_file *initdata_next_bootfile(struct initdata *initdata)
|
struct vm_file *initdata_next_bootfile(struct initdata *initdata)
|
||||||
{
|
{
|
||||||
struct vm_file *file, *n;
|
struct vm_file *file, *n;
|
||||||
list_foreach_removable_struct(file, n, &initdata->boot_file_list,
|
list_foreach_removable_struct(file, n,
|
||||||
list) {
|
&initdata->boot_file_list,
|
||||||
|
list) {
|
||||||
list_remove_init(&file->list);
|
list_remove_init(&file->list);
|
||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
@@ -175,7 +178,8 @@ int start_boot_tasks(struct initdata *initdata)
|
|||||||
ids.spid = PAGER_TID;
|
ids.spid = PAGER_TID;
|
||||||
ids.tgid = PAGER_TID;
|
ids.tgid = PAGER_TID;
|
||||||
|
|
||||||
if (mm0_task_init(mm0_file, INITTASK_AREA_START, INITTASK_AREA_END, &ids) < 0)
|
if (mm0_task_init(mm0_file, INITTASK_AREA_START,
|
||||||
|
INITTASK_AREA_END, &ids) < 0)
|
||||||
BUG();
|
BUG();
|
||||||
total++;
|
total++;
|
||||||
|
|
||||||
@@ -185,22 +189,24 @@ int start_boot_tasks(struct initdata *initdata)
|
|||||||
ids.tgid = VFS_TID;
|
ids.tgid = VFS_TID;
|
||||||
|
|
||||||
// printf("%s: Initialising fs0\n",__TASKNAME__);
|
// printf("%s: Initialising fs0\n",__TASKNAME__);
|
||||||
BUG_ON((IS_ERR(fs0_task = boottask_exec(fs0_file, USER_AREA_START, USER_AREA_END, &ids))));
|
BUG_ON((IS_ERR(fs0_task = boottask_exec(fs0_file, USER_AREA_START,
|
||||||
|
USER_AREA_END, &ids))));
|
||||||
total++;
|
total++;
|
||||||
|
|
||||||
/* Initialise other tasks */
|
/* Initialise other tasks */
|
||||||
list_foreach_removable_struct(file, n, &other_files, list) {
|
list_foreach_removable_struct(file, n, &other_files, list) {
|
||||||
// printf("%s: Initialising new boot task.\n", __TASKNAME__);
|
|
||||||
ids.tid = TASK_ID_INVALID;
|
ids.tid = TASK_ID_INVALID;
|
||||||
ids.spid = TASK_ID_INVALID;
|
ids.spid = TASK_ID_INVALID;
|
||||||
ids.tgid = TASK_ID_INVALID;
|
ids.tgid = TASK_ID_INVALID;
|
||||||
list_remove_init(&file->list);
|
list_remove_init(&file->list);
|
||||||
BUG_ON(IS_ERR(boottask_exec(file, USER_AREA_START, USER_AREA_END, &ids)));
|
BUG_ON(IS_ERR(boottask_exec(file, USER_AREA_START,
|
||||||
|
USER_AREA_END, &ids)));
|
||||||
total++;
|
total++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!total) {
|
if (!total) {
|
||||||
printf("%s: Could not start any tasks.\n", __TASKNAME__);
|
printf("%s: Could not start any tasks.\n",
|
||||||
|
__TASKNAME__);
|
||||||
BUG();
|
BUG();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -242,38 +248,29 @@ void init_mm(struct initdata *initdata)
|
|||||||
|
|
||||||
init_physmem_secondary(initdata, membank);
|
init_physmem_secondary(initdata, membank);
|
||||||
|
|
||||||
// printf("%s: Initialised physmem.\n", __TASKNAME__);
|
|
||||||
|
|
||||||
/* Initialise the page allocator on first bank. */
|
/* Initialise the page allocator on first bank. */
|
||||||
init_page_allocator(membank[0].free, membank[0].end);
|
init_page_allocator(membank[0].free, membank[0].end);
|
||||||
// printf("%s: Initialised page allocator.\n", __TASKNAME__);
|
|
||||||
|
|
||||||
/* Initialise the zero page */
|
/* Initialise the zero page */
|
||||||
init_devzero();
|
init_devzero();
|
||||||
// printf("%s: Initialised devzero.\n", __TASKNAME__);
|
|
||||||
|
|
||||||
/* Initialise in-memory boot files */
|
/* Initialise in-memory boot files */
|
||||||
init_boot_files(initdata);
|
init_boot_files(initdata);
|
||||||
// printf("%s: Initialised in-memory boot files.\n", __TASKNAME__);
|
|
||||||
|
|
||||||
if (shm_pool_init() < 0) {
|
if (shm_pool_init() < 0) {
|
||||||
printf("SHM initialisation failed.\n");
|
printf("SHM initialisation failed.\n");
|
||||||
BUG();
|
BUG();
|
||||||
}
|
}
|
||||||
// printf("%s: Initialised shm structures.\n", __TASKNAME__);
|
|
||||||
|
|
||||||
if (utcb_pool_init() < 0) {
|
if (utcb_pool_init() < 0) {
|
||||||
printf("SHM initialisation failed.\n");
|
printf("SHM initialisation failed.\n");
|
||||||
BUG();
|
BUG();
|
||||||
}
|
}
|
||||||
|
|
||||||
// printf("%s: Initialised utcb address pool.\n", __TASKNAME__);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void init_pager(void)
|
void init_pager(void)
|
||||||
{
|
{
|
||||||
/* For supplying contiguous virtual addresses to pager */
|
|
||||||
pager_address_pool_init();
|
pager_address_pool_init();
|
||||||
|
|
||||||
read_kernel_capabilities(&initdata);
|
read_kernel_capabilities(&initdata);
|
||||||
@@ -284,7 +281,6 @@ void init_pager(void)
|
|||||||
|
|
||||||
start_boot_tasks(&initdata);
|
start_boot_tasks(&initdata);
|
||||||
|
|
||||||
/* Copy necessary initdata info */
|
|
||||||
copy_release_initdata(&initdata);
|
copy_release_initdata(&initdata);
|
||||||
|
|
||||||
mm0_test_global_vm_integrity();
|
mm0_test_global_vm_integrity();
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ static struct pager_virtual_address_id_pool {
|
|||||||
/* End of pager image */
|
/* End of pager image */
|
||||||
extern unsigned char _end[];
|
extern unsigned char _end[];
|
||||||
|
|
||||||
|
/* For supplying contiguous virtual addresses to pager */
|
||||||
int pager_address_pool_init(void)
|
int pager_address_pool_init(void)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
|
|||||||
Reference in New Issue
Block a user