mirror of
https://github.com/drasko/codezero.git
synced 2026-01-27 10:13:15 +01:00
First working Codezero & POSIX Services with container/capability changes
This commit is contained in:
@@ -152,13 +152,6 @@ static inline void set_task_ids(struct ktcb *task, struct task_ids *ids)
|
|||||||
task->tgid = ids->tgid;
|
task->tgid = ids->tgid;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define THREAD_IDS_MAX 1024
|
|
||||||
#define SPACE_IDS_MAX 1024
|
|
||||||
|
|
||||||
|
|
||||||
extern struct id_pool *thread_id_pool;
|
|
||||||
extern struct id_pool *space_id_pool;
|
|
||||||
|
|
||||||
struct ktcb *tcb_find(l4id_t tid);
|
struct ktcb *tcb_find(l4id_t tid);
|
||||||
void tcb_add(struct ktcb *tcb);
|
void tcb_add(struct ktcb *tcb);
|
||||||
void tcb_remove(struct ktcb *tcb);
|
void tcb_remove(struct ktcb *tcb);
|
||||||
|
|||||||
@@ -226,13 +226,17 @@ int arch_setup_new_thread(struct ktcb *new, struct ktcb *orig,
|
|||||||
int thread_setup_new_ids(struct task_ids *ids, unsigned int flags,
|
int thread_setup_new_ids(struct task_ids *ids, unsigned int flags,
|
||||||
struct ktcb *new, struct ktcb *orig)
|
struct ktcb *new, struct ktcb *orig)
|
||||||
{
|
{
|
||||||
|
ids->tid = new->tid;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If thread space is new or copied,
|
* If thread space is new or copied,
|
||||||
* thread gets same group id as its thread id
|
* thread gets same group id as its thread id
|
||||||
*/
|
*/
|
||||||
if (flags == THREAD_NEW_SPACE ||
|
if (flags == THREAD_NEW_SPACE ||
|
||||||
flags == THREAD_COPY_SPACE)
|
flags == THREAD_COPY_SPACE) {
|
||||||
ids->tgid = ids->tid;
|
ids->tgid = ids->tid;
|
||||||
|
new->tgid = new->tid;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If the tgid of original thread is supplied, that implies the
|
* If the tgid of original thread is supplied, that implies the
|
||||||
@@ -240,11 +244,13 @@ int thread_setup_new_ids(struct task_ids *ids, unsigned int flags,
|
|||||||
* it is. Otherwise the thread gets the same group id as its
|
* it is. Otherwise the thread gets the same group id as its
|
||||||
* unique thread id.
|
* unique thread id.
|
||||||
*/
|
*/
|
||||||
if (flags == THREAD_SAME_SPACE && ids->tgid != orig->tgid)
|
if (flags == THREAD_SAME_SPACE && ids->tgid != orig->tgid) {
|
||||||
ids->tgid = ids->tid;
|
ids->tgid = ids->tid;
|
||||||
|
new->tgid = new->tid;
|
||||||
|
}
|
||||||
|
|
||||||
/* Set all ids */
|
/* Set all ids */
|
||||||
set_task_ids(new, ids);
|
//set_task_ids(new, ids);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -296,11 +302,10 @@ out:
|
|||||||
int thread_create(struct task_ids *ids, unsigned int flags)
|
int thread_create(struct task_ids *ids, unsigned int flags)
|
||||||
{
|
{
|
||||||
struct ktcb *new;
|
struct ktcb *new;
|
||||||
struct ktcb *parent;
|
struct ktcb *parent = 0;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
flags &= THREAD_CREATE_MASK;
|
flags &= THREAD_CREATE_MASK;
|
||||||
parent = 0;
|
|
||||||
|
|
||||||
if (!(new = tcb_alloc_init()))
|
if (!(new = tcb_alloc_init()))
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
@@ -337,7 +342,7 @@ int thread_create(struct task_ids *ids, unsigned int flags)
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
out_err:
|
out_err:
|
||||||
/* Pre-mature tcb needs freeing by free_page */
|
/* Pre-mature tcb needs freeing by free_ktcb */
|
||||||
free_ktcb(new);
|
free_ktcb(new);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
#include <l4/generic/preempt.h>
|
#include <l4/generic/preempt.h>
|
||||||
#include <l4/generic/space.h>
|
#include <l4/generic/space.h>
|
||||||
#include <l4/lib/idpool.h>
|
#include <l4/lib/idpool.h>
|
||||||
|
#include <l4/api/ipc.h>
|
||||||
#include <l4/api/kip.h>
|
#include <l4/api/kip.h>
|
||||||
#include <l4/api/errno.h>
|
#include <l4/api/errno.h>
|
||||||
#include INC_ARCH(exception.h)
|
#include INC_ARCH(exception.h)
|
||||||
@@ -25,8 +26,6 @@ void init_ktcb_list(struct ktcb_list *ktcb_list)
|
|||||||
|
|
||||||
void tcb_init(struct ktcb *new)
|
void tcb_init(struct ktcb *new)
|
||||||
{
|
{
|
||||||
new->tid = id_new(&kernel_container.ktcb_ids);
|
|
||||||
new->tgid = new->tid;
|
|
||||||
|
|
||||||
link_init(&new->task_list);
|
link_init(&new->task_list);
|
||||||
mutex_init(&new->thread_control_lock);
|
mutex_init(&new->thread_control_lock);
|
||||||
@@ -51,11 +50,19 @@ struct ktcb *tcb_alloc(void)
|
|||||||
struct ktcb *tcb_alloc_init(void)
|
struct ktcb *tcb_alloc_init(void)
|
||||||
{
|
{
|
||||||
struct ktcb *tcb;
|
struct ktcb *tcb;
|
||||||
|
struct task_ids ids;
|
||||||
|
|
||||||
if (!(tcb = tcb_alloc()))
|
if (!(tcb = tcb_alloc()))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
ids.tid = id_new(&kernel_container.ktcb_ids);
|
||||||
|
ids.tgid = L4_NILTHREAD;
|
||||||
|
ids.spid = L4_NILTHREAD;
|
||||||
|
|
||||||
|
set_task_ids(tcb, &ids);
|
||||||
|
|
||||||
tcb_init(tcb);
|
tcb_init(tcb);
|
||||||
|
|
||||||
return tcb;
|
return tcb;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user