mirror of
https://github.com/drasko/codezero.git
synced 2026-01-12 02:43:15 +01:00
Merge branch 'master' into linux
This commit is contained in:
@@ -1,14 +1,11 @@
|
||||
#ifndef __INITTASK_ARCH_MM_H__
|
||||
#define __INITTASK_ARCH_MM_H__
|
||||
|
||||
#include <arch/offsets.h>
|
||||
#include <l4/macros.h>
|
||||
#include <l4/types.h>
|
||||
#include INC_GLUE(memory.h)
|
||||
#include <vm_area.h>
|
||||
|
||||
#define INITTASK_ADDR(x) ((x >= INITTASK_AREA_START) && (x < INITTASK_AREA_END))
|
||||
|
||||
struct fault_data;
|
||||
unsigned int vm_prot_flags(pte_t pte);
|
||||
void set_generic_fault_params(struct fault_data *fault);
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
#ifndef __INITTASK_ARCH_OFFSETS_H__
|
||||
#define __INITTASK_ARCH_OFFSETS_H__
|
||||
|
||||
#define INITTASK_AREA_START 0xE0000000
|
||||
#define INITTASK_AREA_END 0xF0000000
|
||||
|
||||
#define INITTASK_OFFSET INITTASK_AREA_START
|
||||
|
||||
#endif
|
||||
@@ -10,6 +10,16 @@
|
||||
#include <init.h>
|
||||
#include <physmem.h>
|
||||
#include <linker.h>
|
||||
#include <capability.h>
|
||||
|
||||
struct container_memory_regions {
|
||||
struct capability *shmem;
|
||||
struct capability *utcb;
|
||||
struct capability *task;
|
||||
struct capability *pager;
|
||||
struct capability *physmem;
|
||||
};
|
||||
extern struct container_memory_regions cont_mem_regions;
|
||||
|
||||
#define PAGER_MMAP_SEGMENT SZ_4MB
|
||||
#define PAGER_MMAP_START (page_align_up(__stack))
|
||||
|
||||
@@ -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 "
|
||||
|
||||
@@ -43,17 +43,13 @@ struct memdesc physmem; /* Initial, primitive memory descriptor */
|
||||
struct membank membank[1]; /* The memory bank */
|
||||
struct page *page_array; /* The physical page array based on mem bank */
|
||||
|
||||
struct container_memory_regions {
|
||||
struct capability *shmem;
|
||||
struct capability *utcb;
|
||||
struct capability *task;
|
||||
struct capability *pager;
|
||||
struct capability *physmem;
|
||||
} cont_mem_regions;
|
||||
|
||||
/* Capability descriptor list */
|
||||
struct cap_list capability_list;
|
||||
|
||||
/* Memory region capabilities */
|
||||
struct container_memory_regions cont_mem_regions;
|
||||
|
||||
__initdata static struct capability *caparray;
|
||||
__initdata static int total_caps = 0;
|
||||
|
||||
@@ -117,8 +113,8 @@ int pager_setup_task(void)
|
||||
task->map_end = PAGER_MMAP_END;
|
||||
|
||||
/* Task's total map boundaries */
|
||||
task->start = task->text_start;
|
||||
task->end = 0xF0000000;
|
||||
task->start = __pfn_to_addr(cont_mem_regions.pager->start);
|
||||
task->end = __pfn_to_addr(cont_mem_regions.pager->end);
|
||||
|
||||
/*
|
||||
* Map all regions as anonymous (since no real
|
||||
@@ -146,7 +142,8 @@ 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,
|
||||
@@ -192,8 +189,6 @@ int read_pager_capabilities()
|
||||
" capabilities failed.\n Could not "
|
||||
"complete CAP_CONTROL_NCAPS request.\n");
|
||||
BUG();
|
||||
} else {
|
||||
printf("There are %d capabilities defined.\n", ncaps);
|
||||
}
|
||||
total_caps = ncaps;
|
||||
|
||||
@@ -225,16 +220,16 @@ int read_pager_capabilities()
|
||||
if ((cap->type & CAP_RTYPE_MASK)
|
||||
== CAP_RTYPE_VIRTMEM) {
|
||||
|
||||
printf("Capability range 0x%lx - 0x%lx\n",
|
||||
__pfn_to_addr(cap->start), __pfn_to_addr(cap->end));
|
||||
/* Pager address region (get from linker-defined) */
|
||||
if (__pfn_to_addr(cap->start)
|
||||
== (unsigned long)virtual_base)
|
||||
cont_mem_regions.pager = cap;
|
||||
|
||||
/* UTCB address region */
|
||||
else if (UTCB_REGION_START == __pfn_to_addr(cap->start)) {
|
||||
if (UTCB_REGION_END != __pfn_to_addr(cap->end)) {
|
||||
else if (UTCB_REGION_START ==
|
||||
__pfn_to_addr(cap->start)) {
|
||||
if (UTCB_REGION_END !=
|
||||
__pfn_to_addr(cap->end)) {
|
||||
printf("FATAL: Region designated "
|
||||
"for UTCB allocation does not "
|
||||
"match on start/end marks");
|
||||
@@ -251,8 +246,10 @@ int read_pager_capabilities()
|
||||
}
|
||||
|
||||
/* Shared memory disjoint region */
|
||||
else if (SHMEM_REGION_START == __pfn_to_addr(cap->start)) {
|
||||
if (SHMEM_REGION_END != __pfn_to_addr(cap->end)) {
|
||||
else if (SHMEM_REGION_START ==
|
||||
__pfn_to_addr(cap->start)) {
|
||||
if (SHMEM_REGION_END !=
|
||||
__pfn_to_addr(cap->end)) {
|
||||
printf("FATAL: Region designated "
|
||||
"for SHM allocation does not "
|
||||
"match on start/end marks");
|
||||
@@ -263,11 +260,13 @@ int read_pager_capabilities()
|
||||
}
|
||||
|
||||
/* Task memory region */
|
||||
else if (TASK_REGION_START == __pfn_to_addr(cap->start)) {
|
||||
if (TASK_REGION_END != __pfn_to_addr(cap->end)) {
|
||||
else if (TASK_REGION_START ==
|
||||
__pfn_to_addr(cap->start)) {
|
||||
if (TASK_REGION_END !=
|
||||
__pfn_to_addr(cap->end)) {
|
||||
printf("FATAL: Region designated "
|
||||
"for Task address space does not "
|
||||
"match on start/end marks");
|
||||
"for Task address space does"
|
||||
"not match on start/end mark.");
|
||||
BUG();
|
||||
}
|
||||
cont_mem_regions.task = cap;
|
||||
@@ -283,7 +282,9 @@ int read_pager_capabilities()
|
||||
printf("%s: Error, pager does not have one of the required"
|
||||
"mem capabilities defined. (TASK, SHM, PHYSMEM, UTCB)\n",
|
||||
__TASKNAME__);
|
||||
printf("%p, %p, %p, %p, %p\n", cont_mem_regions.task, cont_mem_regions.shmem, cont_mem_regions.utcb, cont_mem_regions.physmem, cont_mem_regions.pager);
|
||||
printf("%p, %p, %p, %p, %p\n", cont_mem_regions.task,
|
||||
cont_mem_regions.shmem, cont_mem_regions.utcb,
|
||||
cont_mem_regions.physmem, cont_mem_regions.pager);
|
||||
BUG();
|
||||
}
|
||||
|
||||
|
||||
@@ -57,10 +57,11 @@ static struct pager_virtual_address_id_pool {
|
||||
*/
|
||||
int pager_address_pool_init(void)
|
||||
{
|
||||
address_pool_init_with_idpool(&pager_vaddr_pool,
|
||||
(struct id_pool *)
|
||||
&pager_virtual_address_id_pool,
|
||||
PAGER_MMAP_END, 0xF0000000);
|
||||
address_pool_init_with_idpool(&pager_vaddr_pool,
|
||||
(struct id_pool *)
|
||||
&pager_virtual_address_id_pool,
|
||||
PAGER_MMAP_END,
|
||||
__pfn_to_addr(cont_mem_regions.pager->end));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user