mirror of
https://github.com/drasko/codezero.git
synced 2026-02-27 01:03:14 +01:00
A comprehensive overhaul on the thread library.
Lots of polishing, organizational changes, bug fixes, error handling etc. are introduced. COPY and NEW space thread creation are allowed but not thoroughly tested yet. It seems they will work best if the lib supports utcb virtual range management through the mapping.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Address allocation pool
|
||||
* Address allocation pool.
|
||||
*
|
||||
* Copyright (C) 2007 Bahadir Balban
|
||||
*/
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
/*
|
||||
* Stack region helper routines.
|
||||
* Stack space helper routines.
|
||||
*
|
||||
* Copyright (C) 2009 B Labs Ltd.
|
||||
*/
|
||||
#ifndef __LIB_STACK_H__
|
||||
#define __LIB_STACK_H__
|
||||
|
||||
/* Symbolic constants and macros */
|
||||
/* Checks if l4_set_stack_params is called. */
|
||||
#define IS_STACK_SETUP() (lib_stack_size)
|
||||
|
||||
int stack_pool_init(unsigned long stack_start,
|
||||
unsigned long stack_end,
|
||||
unsigned long stack_size);
|
||||
|
||||
void *get_stack_space(int nitems, int size);
|
||||
int delete_stack_space(void *stack_address, int nitems, int size);
|
||||
void *get_stack_space(void);
|
||||
int delete_stack_space(void *stack_address);
|
||||
|
||||
#endif /* __LIB_STACK_H__ */
|
||||
|
||||
@@ -14,23 +14,30 @@ struct utcb_head {
|
||||
};
|
||||
|
||||
/* A simple thread control block for the thread library. */
|
||||
struct l4t_tcb {
|
||||
struct tcb {
|
||||
/* Task list */
|
||||
struct link list;
|
||||
|
||||
/* Task id */
|
||||
int tid;
|
||||
|
||||
/* Chain of utcb descriptors */
|
||||
struct utcb_head *utcb_head;
|
||||
|
||||
/* Stack and utcb address */
|
||||
unsigned long utcb_addr;
|
||||
unsigned long stack_addr;
|
||||
};
|
||||
|
||||
/* This struct keeps track of all the threads handled by the thread lib. */
|
||||
struct l4t_global_list {
|
||||
/* All the threads handled by the thread lib are kept in this list. */
|
||||
struct global_list {
|
||||
int total;
|
||||
struct link list;
|
||||
};
|
||||
|
||||
struct l4t_tcb *l4t_find_task(int tid);
|
||||
struct l4t_tcb *l4t_tcb_alloc_init(struct l4t_tcb *parent, unsigned int flags);
|
||||
void l4t_global_add_task(struct l4t_tcb *task);
|
||||
void l4t_global_remove_task(struct l4t_tcb *task);
|
||||
struct tcb *find_task(int tid);
|
||||
struct tcb *tcb_alloc_init(struct tcb *parent, unsigned int flags);
|
||||
void global_add_task(struct tcb *task);
|
||||
void global_remove_task(struct tcb *task);
|
||||
|
||||
#endif /* __LIB_TCB_H__ */
|
||||
|
||||
@@ -12,7 +12,7 @@ int l4_set_stack_params(unsigned long stack_top,
|
||||
int l4_set_utcb_params(unsigned long utcb_start, unsigned long utcb_end);
|
||||
|
||||
int l4_thread_create(struct task_ids *ids, unsigned int flags,
|
||||
void *(*func)(void *), void *arg);
|
||||
void l4_thread_exit(void *retval);
|
||||
int (*func)(void *), void *arg);
|
||||
void l4_thread_exit(int retval);
|
||||
|
||||
#endif /* __LIB_THREAD_H__ */
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* UTCB handling helper routines
|
||||
* UTCB handling helper routines.
|
||||
*
|
||||
* Copyright (C) 2009 B Labs Ltd.
|
||||
*/
|
||||
@@ -8,7 +8,10 @@
|
||||
|
||||
#include <tcb.h>
|
||||
|
||||
unsigned long get_utcb_addr(struct l4t_tcb *task);
|
||||
int delete_utcb_addr(struct l4t_tcb *task);
|
||||
/* Checks if l4_set_stack_params is called. */
|
||||
#define IS_UTCB_SETUP() (lib_utcb_range_size)
|
||||
|
||||
unsigned long get_utcb_addr(struct tcb *task);
|
||||
int delete_utcb_addr(struct tcb *task);
|
||||
|
||||
#endif /* __LIB_UTCB_H__ */
|
||||
|
||||
Reference in New Issue
Block a user