mirror of
https://github.com/drasko/codezero.git
synced 2026-01-20 14:53:16 +01:00
Moved all threading functions to libl4/include/l4lib/thread/*
This commit is contained in:
19
conts/libl4/include/l4lib/thread/stack.h
Normal file
19
conts/libl4/include/l4lib/thread/stack.h
Normal 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__ */
|
||||
43
conts/libl4/include/l4lib/thread/tcb.h
Normal file
43
conts/libl4/include/l4lib/thread/tcb.h
Normal 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__ */
|
||||
32
conts/libl4/include/l4lib/thread/thread.h
Normal file
32
conts/libl4/include/l4lib/thread/thread.h
Normal 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__ */
|
||||
33
conts/libl4/include/l4lib/thread/utcb-common.h
Normal file
33
conts/libl4/include/l4lib/thread/utcb-common.h
Normal 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__ */
|
||||
Reference in New Issue
Block a user