mirror of
https://github.com/drasko/codezero.git
synced 2026-03-28 23:09:03 +01:00
Modified task initialisation so that stack now comes beneath the environment
Environment is backed by a special per-task file maintained by mm0 for each task. This file is filled in by the env pager, by simple copying of env data into the faulty page upon a fault. UTCB and all anon regions (stack) could use the same scheme. Fixed IS_ERR(x) to accept negative values that are above -1000 for errors. This protects against false positives for pointers such as 0xE0000000. modified: include/l4/generic/scheduler.h modified: include/l4/macros.h modified: src/arch/arm/exception.c modified: tasks/fs0/include/linker.lds modified: tasks/libl4/src/init.c modified: tasks/libposix/shm.c new file: tasks/mm0/include/env.h modified: tasks/mm0/include/file.h new file: tasks/mm0/include/lib/addr.h deleted: tasks/mm0/include/lib/vaddr.h modified: tasks/mm0/include/task.h new file: tasks/mm0/include/utcb.h new file: tasks/mm0/src/env.c modified: tasks/mm0/src/fault.c modified: tasks/mm0/src/file.c modified: tasks/mm0/src/init.c new file: tasks/mm0/src/lib/addr.c modified: tasks/mm0/src/lib/idpool.c deleted: tasks/mm0/src/lib/vaddr.c modified: tasks/mm0/src/mmap.c modified: tasks/mm0/src/shm.c modified: tasks/mm0/src/task.c new file: tasks/mm0/src/utcb.c modified: tasks/test0/include/linker.lds
This commit is contained in:
44
tasks/mm0/src/lib/addr.c
Normal file
44
tasks/mm0/src/lib/addr.c
Normal file
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* This module allocates an unused address range from
|
||||
* a given memory region defined as the pool range.
|
||||
*
|
||||
* Copyright (C) 2007 Bahadir Balban
|
||||
*/
|
||||
#include <lib/bit.h>
|
||||
#include <l4/macros.h>
|
||||
#include <l4/types.h>
|
||||
#include INC_GLUE(memory.h)
|
||||
#include <lib/addr.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int address_pool_init(struct address_pool *pool, unsigned long start, unsigned long end)
|
||||
{
|
||||
if ((pool->idpool = id_pool_new_init(__pfn(end - start))) < 0)
|
||||
return (int)pool->idpool;
|
||||
pool->start = start;
|
||||
pool->end = end;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void *address_new(struct address_pool *pool, int npages)
|
||||
{
|
||||
unsigned int pfn;
|
||||
|
||||
if ((int)(pfn = ids_new_contiguous(pool->idpool, npages)) < 0)
|
||||
return 0;
|
||||
|
||||
return (void *)__pfn_to_addr(pfn) + pool->start;
|
||||
}
|
||||
|
||||
int address_del(struct address_pool *pool, void *addr, int npages)
|
||||
{
|
||||
unsigned long pfn = __pfn(page_align(addr) - pool->start);
|
||||
|
||||
if (ids_del_contiguous(pool->idpool, pfn, npages) < 0) {
|
||||
printf("%s: Invalid address range returned to "
|
||||
"virtual address pool.\n", __FUNCTION__);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -7,12 +7,15 @@
|
||||
#include <kmalloc/kmalloc.h>
|
||||
#include INC_GLUE(memory.h)
|
||||
#include <stdio.h>
|
||||
#include <l4/api/errno.h>
|
||||
|
||||
struct id_pool *id_pool_new_init(int totalbits)
|
||||
{
|
||||
int nwords = BITWISE_GETWORD(totalbits);
|
||||
struct id_pool *new = kzalloc((nwords * SZ_WORD)
|
||||
+ sizeof(struct id_pool));
|
||||
if (!new)
|
||||
return PTR_ERR(-ENOMEM);
|
||||
new->nwords = nwords;
|
||||
return new;
|
||||
}
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
/*
|
||||
* This module allocates an unused virtual address range for shm segments.
|
||||
*
|
||||
* Copyright (C) 2007 Bahadir Balban
|
||||
*/
|
||||
#include <lib/bit.h>
|
||||
#include <l4/macros.h>
|
||||
#include <l4/types.h>
|
||||
#include INC_GLUE(memory.h)
|
||||
#include <lib/vaddr.h>
|
||||
#include <stdio.h>
|
||||
|
||||
void vaddr_pool_init(struct id_pool *pool, unsigned long start, unsigned long end)
|
||||
{
|
||||
pool = id_pool_new_init(__pfn(end - start));
|
||||
}
|
||||
|
||||
void *vaddr_new(struct id_pool *pool, int npages)
|
||||
{
|
||||
unsigned int shm_vpfn;
|
||||
|
||||
if ((int)(shm_vpfn = ids_new_contiguous(pool, npages)) < 0)
|
||||
return 0;
|
||||
|
||||
return (void *)__pfn_to_addr(shm_vpfn + SHM_AREA_START);
|
||||
}
|
||||
|
||||
int vaddr_del(struct id_pool *pool, void *vaddr, int npages)
|
||||
{
|
||||
unsigned long idpfn = __pfn(page_align(vaddr) - SHM_AREA_START);
|
||||
|
||||
if (ids_del_contiguous(pool, idpfn, npages) < 0) {
|
||||
printf("%s: Invalid address range returned to "
|
||||
"virtual address pool.\n", __FUNCTION__);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user