commited some changes and added README
[meinos.git] / kernel2 / include / procm.h
blobf5c507788c2a5990e9f4affe92be77cae2b94316
1 /*
2 meinOS - A unix-like x86 microkernel operating system
3 Copyright (C) 2008 Janosch Gräf <janosch.graef@gmx.net>
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
20 #ifndef _PROCM_H_
21 #define _PROCM_H_
23 typedef struct proc_S proc_t;
25 #include <sys/types.h>
26 #include <stdint.h>
27 #include <paging.h>
28 #include <llist.h>
29 #include <memuser.h>
30 #include <ipc.h>
31 #include <vm86.h>
33 #define NICE2TICKS(nice) 1 /*(50-((nice)+20))*/
35 struct proc_registers {
36 uint32_t eax;
37 uint32_t ebx;
38 uint32_t ecx;
39 uint32_t edx;
40 uint32_t esi;
41 uint32_t edi;
42 uint32_t ebp;
43 uint32_t esp;
44 uint32_t eip;
45 uint32_t efl;
46 uint32_t cs;
47 uint32_t ds;
48 uint32_t es;
49 uint32_t fs;
50 uint32_t gs;
51 uint32_t ss;
54 /// Process structure
55 /// @todo do check for system instead for root-uid/gid
56 /// @todo move uid/gid to var
57 struct proc_S {
58 /// Process ID
59 pid_t pid;
61 /// Owner UID
62 uid_t uid,euid,suid;
64 /// Owner GID
65 gid_t gid,egid,sgid;
67 /// If system process
68 int system;
70 /// Process name
71 char *name;
73 /// Parent process
74 proc_t *parent;
76 /// Children
77 llist_t children;
79 /// Primary registers
80 struct proc_registers registers;
82 /// Address space
83 addrspace_t *addrspace;
85 /// Time handlers
86 llist_t time_handler;
88 /// Nice value
89 int nice;
91 /// Remaining ticks
92 clock_t ticks_rem;
94 /// Whether process sleeps
95 int is_sleeping;
97 /// Private variable
98 int var;
100 /// If process is defunc
101 int defunc;
103 /// Return value
104 int ret;
106 /// Signal handler
107 void (*signal)(int);
109 /// Is VM8086 process
110 int is_vm86;
112 /// VM8086 Pagedir
113 pd_t vm86_pagedir;
115 /// waitpid()
116 int wait;
117 pid_t wait_pid;
118 int *wait_stat;
120 /// VM8086 segment registers
121 struct vm86_segmentregs vm86_segregs;
124 llist_t proc_all;
125 llist_t proc_running;
126 llist_t proc_sleeping;
127 pid_t proc_nextpid;
128 proc_t *proc_current;
130 int proc_init();
131 proc_t *proc_create(char *name,uid_t uid,gid_t gid,proc_t *parent,int system,int running);
132 int proc_destroy(proc_t *proc);
133 proc_t *proc_find(pid_t pid);
134 int proc_sleep(proc_t *proc);
135 int proc_wake(proc_t *proc);
136 void proc_shedule();
137 pid_t proc_getpid();
138 pid_t proc_getparent(pid_t pid);
139 pid_t proc_getchild(pid_t pid,size_t i);
140 uid_t proc_getuid(int idmask);
141 void proc_setuid(int idmask,uid_t uid);
142 gid_t proc_getgid(int idmask);
143 void proc_setgid(int idmask,gid_t gid);
144 ssize_t proc_getname(pid_t pid,char *buf,size_t maxlen);
145 int proc_setname(pid_t pid,const char *name);
146 pid_t proc_getpidbyname(const char *name);
147 int proc_getvar(pid_t pid);
148 void proc_setvar(pid_t pid,int var);
149 pid_t proc_waitpid(pid_t pid,int *stat_loc,int options);
150 void proc_exit(int ret);
151 void proc_abort();
152 void proc_continue();
153 void proc_stop();
154 void proc_call(proc_t *proc,void *func,size_t numparams,...);
155 void proc_push(proc_t *proc,int val);
156 int proc_pop(proc_t *proc);
157 void proc_idle();
158 pid_t proc_create_syscall(char *name,uid_t uid,gid_t gid,pid_t parent_pid);
159 int proc_destroy_syscall(pid_t proc_pid);
160 void *proc_memmap(pid_t proc_pid,void *virt,void *phys,int writable,int swappable,int cow);
161 int proc_memunmap(pid_t proc_pid,void *virt);
162 int proc_memfree(pid_t proc_pid,void *virt);
163 void *proc_memget(pid_t proc_pid,void *virt,int *exists,int *writable,int *swappable,int *cow);
164 size_t proc_mempagelist(pid_t proc_pid,void **list,size_t n);
165 int proc_memalloc(pid_t proc_pid,void *virt,int writable,int swappable);
166 int proc_system(pid_t proc_pid,int system);
167 int proc_jump(pid_t proc_pid,void *dest);
168 int *proc_createstack(pid_t proc_pid);
169 int *proc_getstack(pid_t proc_pid);
170 int proc_setstack(pid_t proc_pid,int *stack);
172 #endif