Moved all threading functions to libl4/include/l4lib/thread/*

This commit is contained in:
Bahadir Balban
2009-12-02 16:15:47 +02:00
parent d210678085
commit b12349f2e4
12 changed files with 17 additions and 19 deletions

View File

@@ -0,0 +1,19 @@
/*
* Stack space helper routines.
*
* Copyright (C) 2009 B Labs Ltd.
*/
#ifndef __LIB_STACK_H__
#define __LIB_STACK_H__
/* 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(void);
int delete_stack_space(void *stack_address);
#endif /* __LIB_STACK_H__ */

View File

@@ -0,0 +1,43 @@
/*
* Thread control block.
*
* Copyright (C) 2009 B Labs Ltd.
*/
#ifndef __LIB_TCB_H__
#define __LIB_TCB_H__
#include <l4/lib/list.h>
/* Keeps all the struct utcb_descs belonging to a thread group together. */
struct l4lib_utcb_head {
struct link list;
};
/* A simple thread control block for the thread library. */
struct l4lib_tcb {
/* Task list */
struct link list;
/* Task id */
int tid;
/* Chain of utcb descriptors */
struct l4lib_utcb_head *utcb_head;
/* Stack and utcb address */
unsigned long utcb_addr;
unsigned long stack_addr;
};
/* All the threads handled by the thread lib are kept in this list. */
struct l4lib_global_list {
int total;
struct link list;
};
struct l4lib_tcb *l4lib_find_task(int tid);
struct l4lib_tcb *l4_tcb_alloc_init(struct l4lib_tcb *parent, unsigned int flags);
void l4lib_global_add_task(struct l4lib_tcb *task);
void l4lib_global_remove_task(struct l4lib_tcb *task);
#endif /* __LIB_TCB_H__ */

View File

@@ -0,0 +1,32 @@
#ifndef __L4_THREAD_H__
#define __L4_THREAD_H__
#include <libl4/arch/utcb.h>
#include <libl4/arch/types.h>
struct l4_thread_struct {
l4id_t tlid; /* Thread local id */
struct task_ids ids; /* Thread L4-defined ids */
struct utcb *utcb; /* Thread utcb */
unsigned long stack_start; /* Thread start of stack */
};
/* -- Bora start -- */
/* A helper macro easing utcb space creation. */
#define DECLARE_UTCB_SPACE(name, entries) \
char name[(entries + PAGE_SIZE / UTCB_SIZE) * UTCB_SIZE] ALIGN(PAGE_SIZE);
int l4_set_stack_params(unsigned long stack_top,
unsigned long stack_bottom,
unsigned long stack_size);
int l4_set_utcb_params(unsigned long utcb_start, unsigned long utcb_end);
int l4_thread_create(struct task_ids *ids, unsigned int flags,
int (*func)(void *), void *arg);
void l4_thread_exit(int retval);
/* -- Bora start -- */
#endif /* __L4_THREAD_H__ */

View File

@@ -0,0 +1,33 @@
/*
* UTCB handling common helper routines.
*
* Copyright (C) 2009 B Labs Ltd.
*/
#ifndef __UTCB_COMMON_H__
#define __UTCB_COMMON_H__
#include <l4/lib/list.h>
#include <l4lib/thread/tcb.h>
struct l4lib_utcb_desc {
struct link list;
unsigned long utcb_base;
struct id_pool *slots;
};
int utcb_pool_init(unsigned long utcb_start, unsigned long utcb_end);
unsigned long utcb_new_slot(struct l4lib_utcb_desc *desc);
int utcb_delete_slot(struct l4lib_utcb_desc *desc, unsigned long address);
struct l4lib_utcb_desc *utcb_new_desc(void);
int utcb_delete_desc(struct l4lib_utcb_desc *desc);
/* Checks if l4_set_stack_params is called. */
#define IS_UTCB_SETUP() (lib_utcb_range_size)
unsigned long get_utcb_addr(struct l4lib_tcb *task);
int delete_utcb_addr(struct l4lib_tcb *task);
#endif /* __UTCB_COMMON_H__ */