mirror of
https://github.com/drasko/codezero.git
synced 2026-01-14 11:53:15 +01:00
Reimplemented space handling by introducing an address_space structure.
- Fixed potential concurrency bugs due to preemption being enabled. - Introduced a new address space structure to better account for address spaces and page tables. - Currently executes fine up to forking. Will investigate.
This commit is contained in:
@@ -137,6 +137,8 @@ void arch_hardware_flush(pgd_table_t *pgd);
|
||||
void add_section_mapping_init(unsigned int paddr, unsigned int vaddr,
|
||||
unsigned int size, unsigned int flags);
|
||||
|
||||
struct address_space;
|
||||
int copy_user_tables(struct address_space *new, struct address_space *orig);
|
||||
pgd_table_t *copy_page_tables(pgd_table_t *from);
|
||||
void remap_as_pages(void *vstart, void *vend);
|
||||
|
||||
|
||||
@@ -21,15 +21,27 @@
|
||||
#if defined (__KERNEL__)
|
||||
|
||||
#include <l4/lib/list.h>
|
||||
#include <l4/lib/mutex.h>
|
||||
#include INC_SUBARCH(mm.h)
|
||||
|
||||
/* A simple page table with a reference count */
|
||||
struct address_space {
|
||||
l4id_t spid;
|
||||
struct list_head list;
|
||||
struct mutex lock;
|
||||
pgd_table_t *pgd;
|
||||
int ktcb_refs;
|
||||
};
|
||||
|
||||
struct address_space *address_space_create(struct address_space *orig);
|
||||
void address_space_delete(struct address_space *space);
|
||||
void address_space_attach(struct ktcb *tcb, struct address_space *space);
|
||||
struct address_space *address_space_find(l4id_t spid);
|
||||
void address_space_add(struct address_space *space);
|
||||
void address_space_remove(struct address_space *space);
|
||||
void address_space_reference_lock();
|
||||
void address_space_reference_unlock();
|
||||
void init_address_space_list(void);
|
||||
int check_access(unsigned long vaddr, unsigned long size, unsigned int flags);
|
||||
#endif
|
||||
|
||||
|
||||
@@ -109,24 +109,6 @@ union ktcb_union {
|
||||
char kstack[PAGE_SIZE];
|
||||
};
|
||||
|
||||
/* For traversing global task list */
|
||||
extern struct list_head global_task_list;
|
||||
static inline struct ktcb *find_task(l4id_t tid)
|
||||
{
|
||||
struct ktcb *task;
|
||||
|
||||
list_for_each_entry(task, &global_task_list, task_list)
|
||||
if (task->tid == tid)
|
||||
return task;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int add_task_global(struct ktcb *new)
|
||||
{
|
||||
INIT_LIST_HEAD(&new->task_list);
|
||||
list_add(&new->task_list, &global_task_list);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Each task is allocated a unique global id. A thread group can only belong to
|
||||
@@ -151,6 +133,15 @@ extern struct id_pool *thread_id_pool;
|
||||
extern struct id_pool *space_id_pool;
|
||||
extern struct id_pool *tgroup_id_pool;
|
||||
|
||||
struct ktcb *tcb_find(l4id_t tid);
|
||||
void tcb_add(struct ktcb *tcb);
|
||||
void tcb_remove(struct ktcb *tcb);
|
||||
|
||||
void tcb_init(struct ktcb *tcb);
|
||||
struct ktcb *tcb_alloc_init(void);
|
||||
void tcb_delete(struct ktcb *tcb);
|
||||
|
||||
void init_ktcb_list(void);
|
||||
void task_update_utcb(struct ktcb *cur, struct ktcb *next);
|
||||
|
||||
#endif /* __TCB_H__ */
|
||||
|
||||
Reference in New Issue
Block a user