Pager works until end of init_physmem_secondary

This commit is contained in:
Bahadir Balban
2009-08-09 17:22:13 +03:00
parent a45b5676ab
commit 02a3f1ac91
33 changed files with 607 additions and 556 deletions

View File

@@ -4,7 +4,7 @@
Import('env')
# The set of source files associated with this SConscript file.
src_local = ['physmem.c', 'irq.c', 'scheduler.c', 'time.c', 'tcb.c', 'space.c', 'bootm.c', 'resource.c', 'container.c', 'capability.c']
src_local = ['irq.c', 'scheduler.c', 'time.c', 'tcb.c', 'space.c', 'bootm.c', 'resource.c', 'container.c', 'capability.c']
obj = env.Object(src_local)
Return('obj')

View File

@@ -17,15 +17,19 @@
* Add irqs, exceptions
*/
#define CONFIG_CONT0_PAGER_START 0x40000
#define CONFIG_CONT0_PHYS_END 0x1000000
#define CONFIG_CONT0_PHYS_START CONFIG_CONT0_PAGER_START
struct container_info cinfo[] = {
[0] = {
.name = "Codezero POSIX Services",
.npagers = 1,
.pager = {
[0] = {
.pager_lma = __pfn(0x38000),
.pager_lma = __pfn(CONFIG_CONT0_PAGER_START),
.pager_vma = __pfn(0xE0000000),
.pager_size = __pfn(0x96000),
.pager_size = __pfn(0x9F000),
.ncaps = 14,
.caps = {
[0] = {
@@ -67,8 +71,8 @@ struct container_info cinfo[] = {
.access = CAP_MAP_CACHED | CAP_MAP_UNCACHED
| CAP_MAP_READ | CAP_MAP_WRITE
| CAP_MAP_EXEC | CAP_MAP_UNMAP,
.start = __pfn(0x38000),
.end = __pfn(0x1000000), /* 16 MB for all posix services */
.start = __pfn(CONFIG_CONT0_PHYS_START),
.end = __pfn(CONFIG_CONT0_PHYS_END), /* 16 MB for all posix services */
},
[5] = {
.type = CAP_TYPE_IPC | CAP_RTYPE_CONTAINER,
@@ -269,9 +273,13 @@ int init_first_pager(struct pager *pager,
mutex_init(&space->lock);
space->pgd = current_pgd;
/* Initialize container relationships */
task->space = space;
task->container = cont;
pager->tcb = task;
task->pager = pager;
task->container = cont;
link_init(&task->cap_list.caps); /* TODO: Do this in tcb_alloc_init */
task->cap_list_ptr = &pager->cap_list;
/* Map the task's space */
add_mapping_pgd(pager->start_lma, pager->start_vma,
@@ -314,9 +322,12 @@ int init_pager(struct pager *pager, struct container *cont)
task->space = address_space_create(0);
task->container = cont;
/* Initialize container relationships */
pager->tcb = task;
task->pager = pager;
task->container = cont;
link_init(&task->cap_list.caps); /* TODO: Do this in tcb_alloc_init */
task->cap_list_ptr = &pager->cap_list;
add_mapping_pgd(pager->start_lma, pager->start_vma,
page_align_up(pager->memsize),

View File

@@ -1,93 +0,0 @@
/*
* Global physical memory descriptions.
*
* Copyright (C) 2007 Bahadir Balban
*/
#include <l4/generic/physmem.h>
#include <l4/generic/resource.h>
#include <l4/generic/tcb.h>
#include <l4/lib/list.h>
#include <l4/lib/spinlock.h>
#include INC_SUBARCH(mm.h)
#include INC_GLUE(memlayout.h)
#include INC_GLUE(memory.h)
#include INC_PLAT(offsets.h)
#include INC_PLAT(printascii.h)
#include INC_ARCH(linker.h)
struct page_bitmap page_map;
static void init_page_map(unsigned long start, unsigned long end)
{
page_map.pfn_start = __pfn(start);
page_map.pfn_end = __pfn(end);
set_page_map(start, __pfn(end - start), 0);
}
/*
* Marks pages in the global page_map as used or unused.
*
* @start = start page address to set, inclusive.
* @numpages = number of pages to set.
*/
int set_page_map(unsigned long start, int numpages, int val)
{
unsigned long pfn_start = __pfn(start);
unsigned long pfn_end = __pfn(start) + numpages;
unsigned long pfn_err = 0;
if (page_map.pfn_start > pfn_start || page_map.pfn_end < pfn_start) {
pfn_err = pfn_start;
goto error;
}
if (page_map.pfn_end < pfn_end || page_map.pfn_start > pfn_end) {
pfn_err = pfn_end;
goto error;
}
if (val)
for (int i = pfn_start; i < pfn_end; i++)
page_map.map[BITWISE_GETWORD(i)] |= BITWISE_GETBIT(i);
else
for (int i = pfn_start; i < pfn_end; i++)
page_map.map[BITWISE_GETWORD(i)] &= ~BITWISE_GETBIT(i);
return 0;
error:
BUG_MSG("Given page area is out of system page_map range: 0x%lx\n",
pfn_err << PAGE_BITS);
return -1;
}
/* Describes physical memory boundaries of the system. */
struct memdesc physmem;
/* Fills in the physmem structure with free physical memory information */
void physmem_init()
{
unsigned long start = (unsigned long)_start_kernel;
unsigned long end = (unsigned long)_end_kernel;
/* Initialise page map */
init_page_map(PHYS_MEM_START, PHYS_MEM_END);
/* Mark kernel areas as used */
set_page_map(virt_to_phys(start), __pfn(end - start), 1);
/* Map initial pgd area as used */
start = (unsigned long)__pt_start;
end = (unsigned long)__pt_end;
set_page_map(virt_to_phys(TASK_PGD(current)), __pfn(end - start), 1);
physmem.start = PHYS_MEM_START;
physmem.end = PHYS_MEM_END;
physmem.free_cur = __svc_images_end;
physmem.free_end = PHYS_MEM_END;
physmem.numpages = (PHYS_MEM_START - PHYS_MEM_END) / PAGE_SIZE;
}
void memory_init()
{
//init_pgalloc();
}