stdlibc: \!perror()
[meinos.git] / kernel2 / vm86.c
blob782f400277ed98f659b27be9b9d47930a194649c
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/>.
19 #include <procm.h>
20 #include <string.h>
21 #include <gdt.h>
22 #include <memkernel.h>
23 #include <llist.h>
25 proc_t *vm86_proc_create(const char *name,uid_t uid,gid_t gid,proc_t *parent) {
26 proc_t *new = malloc(sizeof(proc_t));
28 new->pid = proc_nextpid++;
29 new->uid = uid;
30 new->euid = uid;
31 new->suid = uid;
32 new->gid = gid;
33 new->egid = gid;
34 new->sgid = gid;
35 new->name = strdup(name);
36 new->parent = parent;
37 if (parent!=NULL) llist_push(parent->children,new);
38 new->children = llist_create();
39 memset(&(new->registers),0,sizeof(new->registers));
40 new->registers.efl = 0x20202;
41 new->registers.cs = IDX2SEL(3,PRIV_USER);
42 new->registers.ds = IDX2SEL(4,PRIV_USER);
43 new->registers.es = IDX2SEL(4,PRIV_USER);
44 new->registers.fs = IDX2SEL(4,PRIV_USER);
45 new->registers.gs = IDX2SEL(4,PRIV_USER);
46 new->registers.ss = IDX2SEL(4,PRIV_USER);
47 new->addrspace = NULL;
48 new->vm86_pagedir = NULL;
49 new->nice = 0;
50 new->ticks_rem = NICE2TICKS(new->nice);
51 new->var = -1;
52 new->defunc = 0;
53 new->is_sleeping = 0;
54 new->signal = NULL;
55 new->is_vm86 = 1;
57 //llist_push(proc_all,new);
58 //llist_push(proc_running,new);
59 return new;
62 void vm86_save_segregs(proc_t *proc) {
63 proc->vm86_segregs.es = *vm86_curregs.es;
64 proc->vm86_segregs.ds = *vm86_curregs.ds;
65 proc->vm86_segregs.fs = *vm86_curregs.fs;
66 proc->vm86_segregs.gs = *vm86_curregs.gs;
69 void vm86_load_segregs(proc_t *proc) {
70 *vm86_curregs.es = proc->vm86_segregs.es;
71 *vm86_curregs.ds = proc->vm86_segregs.ds;
72 *vm86_curregs.fs = proc->vm86_segregs.fs;
73 *vm86_curregs.gs = proc->vm86_segregs.gs;