The second step in creating a thread library.

UTCB support has beed added. It has the same drawback as in the stack support:
the area in question has to be already mapped-in.

There are also some minor fixes for the stack support and the utcb common helper
routines.
This commit is contained in:
Bora Sahin
2009-11-05 15:20:54 +02:00
parent b31ab82437
commit 1256f1a13a
8 changed files with 249 additions and 92 deletions

View File

@@ -18,8 +18,9 @@ struct address_pool {
int address_pool_init_with_idpool(struct address_pool *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);
int address_pool_init(struct address_pool *pool,
unsigned long start, unsigned long end,
int size);
void *address_new(struct address_pool *pool, int npages);
int address_del(struct address_pool *, void *addr, int npages);

View File

@@ -6,13 +6,21 @@
#ifndef __LIB_THREAD_H__
#define __LIB_THREAD_H__
#define STACK_TOP_ADDR(stack) ((unsigned long)(stack))
#define STACK_BOTTOM_ADDR(stack) \
((unsigned long)((stack) + (sizeof(stack))))
#define START_ADDR(addr) ((unsigned long)(addr))
#define END_ADDR(addr) ((unsigned long)((addr) + (sizeof(addr))))
#define STACK_TOP_ADDR(stack) (START_ADDR(stack))
#define STACK_BOTTOM_ADDR(stack) (END_ADDR(stack))
#define UTCB_START_ADDR(utcb) (START_ADDR(utcb))
#define UTCB_END_ADDR(utcb) (END_ADDR(utcb))
int set_stack_params(unsigned long stack_top_addr,
unsigned long stack_bottom_addr,
unsigned long stack_size);
int set_utcb_params(unsigned long utcb_start_addr,
unsigned long utcb_end_addr);
int thread_create(struct task_ids *ids, unsigned int flags,
int (*func)(void *), void *arg);

View File

@@ -0,0 +1,25 @@
/*
* UTCB handling common helper routines
*
* Copyright (C) 2009 B Labs Ltd.
*/
#ifndef __UTCB_COMMON_H__
#define __UTCB_COMMON_H__
#include <l4/lib/list.h>
struct 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 utcb_desc *desc);
int utcb_delete_slot(struct utcb_desc *desc, unsigned long address);
struct utcb_desc *utcb_new_desc(void);
int utcb_delete_desc(struct utcb_desc *desc);
#endif /* __UTCB_COMMON_H__ */

View File

@@ -3,23 +3,13 @@
*
* Copyright (C) 2009 B Labs Ltd.
*/
#ifndef __UTCB_H__
#define __UTCB_H__
#ifndef __LIB_UTCB_H__
#define __LIB_UTCB_H__
#include <l4/lib/list.h>
#define IS_UTCB_SETUP() (udesc_ptr)
struct utcb_desc {
struct link list;
unsigned long utcb_base;
struct id_pool *slots;
};
struct utcb_desc *udesc_ptr;
int utcb_pool_init(unsigned long utcb_start, unsigned long utcb_end);
unsigned long get_utcb_addr(void);
unsigned long utcb_new_slot(struct utcb_desc *desc);
int utcb_delete_slot(struct utcb_desc *desc, unsigned long address);
struct utcb_desc *utcb_new_desc(void);
int utcb_delete_desc(struct utcb_desc *desc);
#endif /* __UTCB_H__ */
#endif /* __LIB_UTCB_H__ */