Replaced all hard-coded values for UTCB, SHM, TASK region assumptions.

Not tested.
Not replaced pager run-area values.
This commit is contained in:
Bahadir Balban
2009-10-15 20:35:41 +03:00
parent 6982e96d1f
commit e9afbbaad9
6 changed files with 25 additions and 15 deletions

View File

@@ -9,6 +9,7 @@
#include INC_GLUE(memory.h)
#include <lib/vaddr.h>
#include <stdio.h>
#include <memory.h>
void vaddr_pool_init(struct id_pool *pool, unsigned long start, unsigned long end)
{
@@ -22,12 +23,13 @@ void *vaddr_new(struct id_pool *pool, int npages)
if ((int)(shm_vpfn = ids_new_contiguous(pool, npages)) < 0)
return 0;
return (void *)__pfn_to_addr(shm_vpfn + SHM_AREA_START);
return (void *)__pfn_to_addr(shm_vpfn + cont_mem_regions.shmem->start);
}
int vaddr_del(struct id_pool *pool, void *vaddr, int npages)
{
unsigned long idpfn = __pfn(page_align(vaddr) - SHM_AREA_START);
unsigned long idpfn = __pfn(page_align(vaddr) -
__pfn_to_addr(cont_mem_regions.shmem->start));
if (ids_del_contiguous(pool, idpfn, npages) < 0) {
printf("%s: Invalid address range returned to "

View File

@@ -142,7 +142,7 @@ int pager_setup_task(void)
* microkernel for this pager. Ensure that we also get
* the same from our internal utcb bookkeeping.
*/
BUG_ON(task->utcb_address != UTCB_AREA_START);
BUG_ON(task->utcb_address != __pfn_to_addr(cont_mem_regions.utcb->start));
/* Pager must prefault its utcb */
prefault_page(task, task->utcb_address,

View File

@@ -169,8 +169,8 @@ int mmap_address_validate(struct tcb *task, unsigned long map_address,
if (vm_flags & VMA_PRIVATE) {
if ((map_address >= task->start &&
map_address < task->end) ||
(map_address >= UTCB_AREA_START &&
map_address < UTCB_AREA_END)) {
(map_address >= __pfn_to_addr(cont_mem_regions.utcb->start) &&
map_address < __pfn_to_addr(cont_mem_regions.utcb->end))) {
return 1;
} else
return 0;
@@ -181,8 +181,8 @@ int mmap_address_validate(struct tcb *task, unsigned long map_address,
} else if (vm_flags & VMA_SHARED) {
if ((map_address >= task->start &&
map_address < task->end) ||
(map_address >= SHM_AREA_START &&
map_address < SHM_AREA_END))
(map_address >= __pfn_to_addr(cont_mem_regions.shmem->start) &&
map_address < __pfn_to_addr(cont_mem_regions.shmem->end)))
return 1;
else
return 0;

View File

@@ -7,6 +7,7 @@
#include <stdio.h>
#include <task.h>
#include <mmap.h>
#include <memory.h>
#include <vm_area.h>
#include <globals.h>
#include <lib/malloc.h>
@@ -62,8 +63,11 @@ int shm_pool_init()
}
/* Initialise the global shm virtual address pool */
if ((err = address_pool_init(&shm_vaddr_pool,
SHM_AREA_START, SHM_AREA_END)) < 0) {
if ((err =
address_pool_init(&shm_vaddr_pool,
__pfn_to_addr(cont_mem_regions.shmem->start),
__pfn_to_addr(cont_mem_regions.shmem->end)))
< 0) {
printf("SHM Address pool initialisation failed.\n");
return err;
}

View File

@@ -519,8 +519,8 @@ int task_map_stack(struct vm_file *f, struct exec_file_desc *efd,
char *args_on_stack;
void *mapped;
task->stack_end = USER_AREA_END;
task->stack_start = USER_AREA_END - DEFAULT_STACK_SIZE;
task->stack_end = __pfn_to_addr(cont_mem_regions.task->end);
task->stack_start = __pfn_to_addr(cont_mem_regions.task->end) - DEFAULT_STACK_SIZE;
task->args_end = task->stack_end;
task->args_start = task->stack_end - stack_used;
@@ -636,8 +636,8 @@ int task_mmap_segments(struct tcb *task, struct vm_file *file, struct exec_file_
int text_size, data_size;
/* Set up task's user boundary regions */
task->start = USER_AREA_START;
task->end = USER_AREA_END;
task->start = __pfn_to_addr(cont_mem_regions.task->start);
task->end = __pfn_to_addr(cont_mem_regions.task->end);
task->map_start = task->start;
task->map_end = task->end;

View File

@@ -10,6 +10,7 @@
#include <utcb.h>
#include <lib/malloc.h>
#include <vm_area.h>
#include <memory.h>
/*
* UTCB management in Codezero
@@ -23,8 +24,11 @@ int utcb_pool_init()
int err;
/* Initialise the global shm virtual address pool */
if ((err = address_pool_init(&utcb_region_pool,
UTCB_AREA_START, UTCB_AREA_END)) < 0) {
if ((err =
address_pool_init(&utcb_region_pool,
__pfn_to_addr(cont_mem_regions.utcb->start),
__pfn_to_addr(cont_mem_regions.utcb->end)))
< 0) {
printf("UTCB address pool initialisation failed.\n");
return err;
}