OpenCores
URL https://opencores.org/ocsvn/c0or1k/c0or1k/trunk

Subversion Repositories c0or1k

[/] [c0or1k/] [trunk/] [conts/] [posix/] [mm0/] [include/] [task.h] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 drasko
/*
2
 * Thread control block.
3
 *
4
 * Copyright (C) 2007, 2008 Bahadir Balban
5
 */
6
#ifndef __TASK_H__
7
#define __TASK_H__
8
 
9
#include <l4/macros.h>
10
#include <l4/types.h>
11
#include INC_GLUE(memlayout.h)
12
#include <l4/lib/list.h>
13
#include L4LIB_INC_ARCH(types.h)
14
#include L4LIB_INC_ARCH(syscalls.h)
15
#include <l4lib/utcb.h>
16
#include <lib/addr.h>
17
#include <l4/api/kip.h>
18
#include <exec.h>
19
 
20
#define __TASKNAME__                    __PAGERNAME__
21
 
22
#define ARGS_MAX                        DEFAULT_ENV_SIZE
23
#define PATH_MAX                        PAGE_SIZE
24
 
25
#define TASK_FILES_MAX                  32
26
 
27
/* POSIX minimum is 4Kb */
28
#define DEFAULT_ENV_SIZE                SZ_4K
29
#define DEFAULT_STACK_SIZE              SZ_32K
30
#define DEFAULT_SHPAGE_SIZE             PAGE_SIZE
31
#define TASK_SIZE                       0x10000000
32
 
33
#define TCB_NO_SHARING                          0
34
#define TCB_SHARED_VM                           (1 << 0)
35
#define TCB_SHARED_FILES                        (1 << 1)
36
#define TCB_SHARED_FS                           (1 << 2)
37
#define TCB_SHARED_TGROUP                       (1 << 3)
38
#define TCB_SHARED_PARENT                       (1 << 4)
39
 
40
struct vm_file;
41
 
42
struct file_descriptor {
43
        unsigned long cursor;
44
        struct vm_file *vmfile;
45
};
46
 
47
struct task_fd_head {
48
        struct file_descriptor fd[TASK_FILES_MAX];
49
        struct id_pool *fdpool;
50
        int tcb_refs;
51
};
52
 
53
struct task_vma_head {
54
        struct link list;
55
        int tcb_refs;
56
};
57
 
58
#define TCB_NO_SHARING                          0
59
#define TCB_SHARED_VM                           (1 << 0)
60
#define TCB_SHARED_FILES                        (1 << 1)
61
#define TCB_SHARED_FS                           (1 << 2)
62
#define TASK_FILES_MAX                  32
63
 
64
struct task_fs_data {
65
        struct vnode *curdir;
66
        struct vnode *rootdir;
67
        int tcb_refs;
68
};
69
 
70
struct utcb_desc {
71
        struct link list;
72
        unsigned long utcb_base;
73
        struct id_pool *slots;
74
};
75
 
76
struct utcb_head {
77
        struct link list;
78
        int tcb_refs;
79
};
80
 
81
 
82
/* Stores all task information that can be kept in userspace. */
83
struct tcb {
84
        /* Task list */
85
        struct link list;
86
 
87
        /* Fields for parent-child relations */
88
        struct link child_ref;  /* Child ref in parent's list */
89
        struct link children;   /* List of children */
90
        struct tcb *parent;             /* Parent task */
91
 
92
        /* Task creation flags */
93
        unsigned int clone_flags;
94
 
95
        /* Name of the task */
96
        char name[16];
97
 
98
        /* Task ids */
99
        l4id_t tid;
100
        l4id_t spid;
101
        l4id_t tgid;
102
 
103
        /* Related task ids */
104
        unsigned int pagerid;           /* Task's pager */
105
 
106
        /* Task's main address space region, usually USER_AREA_START/END */
107
        unsigned long start;
108
        unsigned long end;
109
 
110
        /* Page aligned program segment marks, ends exclusive as usual */
111
        unsigned long entry;
112
        unsigned long text_start;
113
        unsigned long text_end;
114
        unsigned long data_start;
115
        unsigned long data_end;
116
        unsigned long bss_start;
117
        unsigned long bss_end;
118
        unsigned long stack_start;
119
        unsigned long stack_end;
120
        unsigned long heap_start;
121
        unsigned long heap_end;
122
        unsigned long args_start;
123
        unsigned long args_end;
124
 
125
        /* Task's mmappable region */
126
        unsigned long map_start;
127
        unsigned long map_end;
128
 
129
        /* Chain of utcb descriptors */
130
        struct utcb_head *utcb_head;
131
 
132
        /* Unique utcb address of this task */
133
        unsigned long utcb_address;
134
 
135
        /* Virtual memory areas */
136
        struct task_vma_head *vm_area_head;
137
 
138
        /* File descriptors for this task */
139
        struct task_fd_head *files;
140
        struct task_fs_data *fs_data;
141
 
142
};
143
 
144
struct tcb_head {
145
        struct link list;
146
        int total;                      /* Total threads */
147
};
148
 
149
struct tcb *find_task(int tid);
150
void global_add_task(struct tcb *task);
151
void global_remove_task(struct tcb *task);
152
int task_mmap_segments(struct tcb *task, struct vm_file *file, struct exec_file_desc *efd,
153
                        struct args_struct *args, struct args_struct *env);
154
int task_setup_registers(struct tcb *task, unsigned int pc,
155
                         unsigned int sp, l4id_t pager);
156
struct tcb *tcb_alloc_init(unsigned int flags);
157
int tcb_destroy(struct tcb *task);
158
int task_start(struct tcb *task);
159
int copy_tcb(struct tcb *to, struct tcb *from, unsigned int flags);
160
int task_release_vmas(struct task_vma_head *vma_head);
161
struct tcb *task_create(struct tcb *orig,
162
                        struct task_ids *ids,
163
                        unsigned int ctrl_flags,
164
                        unsigned int alloc_flags);
165
int task_prefault_range(struct tcb *task, unsigned long start,
166
                        unsigned long end, unsigned int vm_flags);
167
 
168
#endif /* __TASK_H__ */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.