mirror of
https://github.com/drasko/codezero.git
synced 2026-02-27 09:13:13 +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:
6
tasks/mm0/include/env.h
Normal file
6
tasks/mm0/include/env.h
Normal file
@@ -0,0 +1,6 @@
|
||||
#ifndef __MM0_ENV__
|
||||
#define __MM0_ENV__
|
||||
|
||||
int task_prepare_env_file(struct tcb *t);
|
||||
|
||||
#endif
|
||||
@@ -5,6 +5,7 @@
|
||||
#include <posix/sys/types.h>
|
||||
|
||||
void vmfile_init(void);
|
||||
|
||||
struct vm_file *vmfile_alloc_init(void);
|
||||
int vfs_receive_sys_open(l4id_t sender, l4id_t opener, int fd,
|
||||
unsigned long vnum, unsigned long size);
|
||||
@@ -16,4 +17,5 @@ int sys_read(l4id_t sender, int fd, void *buf, int count);
|
||||
int sys_write(l4id_t sender, int fd, void *buf, int count);
|
||||
int sys_lseek(l4id_t sender, int fd, off_t offset, int whence);
|
||||
|
||||
extern struct list_head vm_file_list;
|
||||
#endif /* __MM0_FILE_H__ */
|
||||
|
||||
23
tasks/mm0/include/lib/addr.h
Normal file
23
tasks/mm0/include/lib/addr.h
Normal file
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Address allocation pool
|
||||
*
|
||||
* Copyright (C) 2007 Bahadir Balban
|
||||
*/
|
||||
#ifndef __ADDR_H__
|
||||
#define __ADDR_H__
|
||||
|
||||
#include <lib/idpool.h>
|
||||
|
||||
/* Address pool to allocate from a range of addresses */
|
||||
struct address_pool {
|
||||
struct id_pool *idpool;
|
||||
unsigned long start;
|
||||
unsigned long end;
|
||||
};
|
||||
|
||||
int address_pool_init(struct address_pool *pool, unsigned long start,
|
||||
unsigned long end);
|
||||
void *address_new(struct address_pool *pool, int npages);
|
||||
int address_del(struct address_pool *, void *addr, int npages);
|
||||
|
||||
#endif /* __ADDR_H__ */
|
||||
@@ -1,17 +0,0 @@
|
||||
/*
|
||||
* Virtual address allocation pool (for shm)
|
||||
*
|
||||
* Copyright (C) 2007 Bahadir Balban
|
||||
*/
|
||||
#ifndef __VADDR_H__
|
||||
#define __VADDR_H__
|
||||
|
||||
#include <lib/idpool.h>
|
||||
|
||||
void vaddr_pool_init(struct id_pool *pool, unsigned long start,
|
||||
unsigned long end);
|
||||
void *vaddr_new(struct id_pool *pool, int npages);
|
||||
int vaddr_del(struct id_pool *, void *vaddr, int npages);
|
||||
|
||||
#endif /* __VADDR_H__ */
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include <l4/lib/list.h>
|
||||
#include <l4lib/types.h>
|
||||
#include <l4lib/utcb.h>
|
||||
#include <lib/addr.h>
|
||||
|
||||
#define __TASKNAME__ __PAGERNAME__
|
||||
|
||||
@@ -43,7 +44,7 @@ struct tcb {
|
||||
/* Related task ids */
|
||||
unsigned int pagerid; /* Task's pager */
|
||||
|
||||
/* Program segment marks */
|
||||
/* Program segment marks, ends exclusive as usual */
|
||||
unsigned long text_start;
|
||||
unsigned long text_end;
|
||||
unsigned long data_start;
|
||||
@@ -51,9 +52,9 @@ struct tcb {
|
||||
unsigned long bss_start;
|
||||
unsigned long bss_end;
|
||||
unsigned long stack_start;
|
||||
unsigned long stack_end; /* Exclusive of last currently mapped page */
|
||||
unsigned long stack_end;
|
||||
unsigned long heap_start;
|
||||
unsigned long heap_end; /* Exclusive of last currently mapped page */
|
||||
unsigned long heap_end;
|
||||
unsigned long env_start;
|
||||
unsigned long env_end;
|
||||
unsigned long args_start;
|
||||
@@ -62,17 +63,24 @@ struct tcb {
|
||||
/* UTCB address */
|
||||
unsigned long utcb_address;
|
||||
|
||||
/* Temporary storage for environment data */
|
||||
void *env_data;
|
||||
unsigned long env_size;
|
||||
|
||||
/* Per-task environment file */
|
||||
struct vm_file *env_file;
|
||||
|
||||
/* Virtual memory areas */
|
||||
struct list_head vm_area_list;
|
||||
|
||||
/* Per-task swap file for now */
|
||||
struct vm_file *swap_file;
|
||||
|
||||
/* File descriptors for this task */
|
||||
struct file_descriptor fd[TASK_OFILES_MAX];
|
||||
|
||||
/* Per-task swap file for now */
|
||||
struct vm_file *swap_file;
|
||||
|
||||
/* Pool to generate swap file offsets for fileless anonymous regions */
|
||||
struct id_pool *swap_file_offset_pool;
|
||||
struct address_pool swap_file_offset_pool;
|
||||
};
|
||||
|
||||
struct tcb *find_task(int tid);
|
||||
|
||||
7
tasks/mm0/include/utcb.h
Normal file
7
tasks/mm0/include/utcb.h
Normal file
@@ -0,0 +1,7 @@
|
||||
#ifndef __MM0_UTCB_H__
|
||||
#define __MM0_UTCB_H__
|
||||
|
||||
void *utcb_vaddr_new(void);
|
||||
int utcb_pool_init(void);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user