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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [uclinux/] [uClinux-2.0.x/] [arch/] [or32/] [kernel/] [process.c] - Blame information for rev 700

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 666 simons
/*
2
 * This file handles the architecture-dependent parts of process handling..
3
 * Based on m86k.
4
 */
5
 
6
#include <linux/config.h>
7
#include <linux/errno.h>
8
#include <linux/sched.h>
9
#include <linux/kernel.h>
10
#include <linux/mm.h>
11
#include <linux/stddef.h>
12
#include <linux/unistd.h>
13
#include <linux/ptrace.h>
14
#include <linux/malloc.h>
15
#include <linux/user.h>
16
#include <linux/a.out.h>
17
 
18
#include <asm/segment.h>
19
#include <asm/system.h>
20
#include <asm/traps.h>
21
#include <asm/machdep.h>
22
#include <asm/board.h>
23
 
24
asmlinkage void ret_from_exception(void);
25
 
26
/*
27
 * The idle loop on an or32..
28
 */
29
asmlinkage int sys_idle(void)
30
{
31
        if (current->pid != 0)
32
                return -EPERM;
33
 
34
 
35
        /* endless idle loop with no priority at all */
36
        current->counter = -100;
37
        for (;;) {
38
                schedule();
39
        }
40
}
41
 
42
void hard_reset_now(void)
43
{
44
        HARD_RESET_NOW();
45
}
46
 
47
void show_regs(struct pt_regs * regs)
48
{
49
        printk("\n");
50
        printk("PC: %08lx  Status: %08lx\n",
51
               regs->pc, regs->sr);
52
        printk("R0 : %08lx  %08lx  %08lx  %08lx  %08lx  %08lx  %08lx  %08lx\n",
53
                0L,            regs->sp,      regs->gprs[0], regs->gprs[1],
54
                regs->gprs[2], regs->gprs[3], regs->gprs[4], regs->gprs[5]);
55
        printk("R8 : %08lx  %08lx  %08lx  %08lx  %08lx  %08lx  %08lx  %08lx\n",
56
                regs->gprs[6], regs->gprs[7], regs->gprs[8], regs->gprs[9],
57
                regs->gprs[10], regs->gprs[11], regs->gprs[12], regs->gprs[13]);
58
        printk("R16: %08lx  %08lx  %08lx  %08lx  %08lx  %08lx  %08lx  %08lx\n",
59
                regs->gprs[14], regs->gprs[15], regs->gprs[16], regs->gprs[17],
60
                regs->gprs[18], regs->gprs[19], regs->gprs[20], regs->gprs[21]);
61
        printk("R24: %08lx  %08lx  %08lx  %08lx  %08lx  %08lx  %08lx  %08lx\n",
62
                regs->gprs[22], regs->gprs[23], regs->gprs[24], regs->gprs[25],
63
                regs->gprs[26], regs->gprs[27], regs->gprs[28], regs->gprs[29]);
64
}
65
 
66
/*
67
 * Free current thread data structures etc..
68
 */
69
void exit_thread(void)
70
{
71
}
72
 
73
void flush_thread(void)
74
{
75
        set_fs(USER_DS);
76
        current->tss.fs = USER_DS;
77
}
78
 
79
asmlinkage int sys_fork(int p1, int p2, int p3, int p4, int p5, struct pt_regs *regs)
80
{
81
        return do_fork(SIGCHLD|CLONE_WAIT, regs->sp, regs);
82
}
83
 
84
asmlinkage int sys_clone(int p1, int p2, int p3, int p4, int p5, struct pt_regs *regs)
85
{
86
        unsigned long clone_flags = (unsigned long)p1;
87 700 simons
        return do_fork(clone_flags, regs->sp, regs);
88 666 simons
}
89
 
90
void release_thread(struct task_struct *dead_task)
91
{
92
}
93
 
94
void copy_thread(int nr, unsigned long clone_flags, unsigned long usp,
95
                 struct task_struct * p, struct pt_regs * regs)
96
{
97
        struct pt_regs * childregs;
98 681 simons
 
99 666 simons
        /* Copy registers */
100 681 simons
        childregs = ((struct pt_regs *) (p->kernel_stack_page + PAGE_SIZE)) - 1;
101 666 simons
        *childregs = *regs;     /* STRUCT COPY */
102 681 simons
        childregs->gprs[9] = 0x0;  /* Result from fork() */
103 666 simons
        p->tss.ksp = childregs;
104
 
105 700 simons
        /* If this is kernel thread, than we can use kernel stack also as
106
           "user" stack, if not, we use user stack from parent which should be a sleep
107
           till we execute execve or exit (that is why sys_fork has CLONE_WAIT
108
           flag allway set ) */
109
        if(regs->sr & SPR_SR_SM) {
110
                childregs->sp = (unsigned long)(childregs+1);
111
                p->tss.usp = (unsigned long)(childregs+1);
112
        }
113
        else {
114
                childregs->sp = usp;
115
                p->tss.usp = usp;
116
        }
117 666 simons
}
118
 
119
/* Fill in the fpu structure for a core dump.  */
120
 
121
int dump_fpu (struct pt_regs *regs, struct user_or32fp_struct *fpu)
122
{
123
  return 0;
124 681 simons
}
125 666 simons
 
126
void switch_to(struct task_struct *prev, struct task_struct *new)
127
{
128
        struct pt_regs *regs;
129
        struct thread_struct *new_tss, *old_tss;
130
        long flags;
131
 
132
        save_flags(flags);
133
        cli();
134
 
135
        regs = (struct pt_regs *)new->tss.ksp;
136
        new_tss = &new->tss;
137
        old_tss = &current->tss;
138
        current_set[0] = new;   /* FIX ME! */
139
        _switch(old_tss, new_tss);
140
        restore_flags(flags);
141
}
142
 
143
/*
144
 * fill in the user structure for a core dump..
145
 */
146
void dump_thread(struct pt_regs * regs, struct user * dump)
147
{
148
/* changed the size calculations - should hopefully work better. lbt */
149
        dump->magic = CMAGIC;
150
        dump->start_code = 0;
151
        dump->start_stack = regs->sp & ~(PAGE_SIZE - 1);
152
        dump->u_tsize = ((unsigned long) current->mm->end_code) >> PAGE_SHIFT;
153
        dump->u_dsize = ((unsigned long) (current->mm->brk +
154
                                          (PAGE_SIZE-1))) >> PAGE_SHIFT;
155
        dump->u_dsize -= dump->u_tsize;
156
        dump->u_ssize = 0;
157
 
158
 
159
        dump->u_ar0 = (struct pt_regs *)(((int)(&dump->regs)) -((int)(dump)));
160
        dump->regs = *regs;
161
        /* dump floating point stuff */
162
        dump->u_fpvalid = dump_fpu (regs, &dump->or32fp);
163
}
164
 
165
/*
166
 * sys_execve() executes a new program.
167
 */
168
asmlinkage int sys_execve(char *name, char **argv, char **envp,
169
                int dummy1, int dummy2, unsigned long sp)
170
{
171
        int error;
172
        char * filename;
173
        struct pt_regs *regs = (struct pt_regs *) sp;
174
 
175 700 simons
_print("%s - %s:%d\n",__FILE__,__FUNCTION__,__LINE__);
176 666 simons
        error = getname(name, &filename);
177 700 simons
_print("%s - %s:%d\n",__FILE__,__FUNCTION__,__LINE__);
178 666 simons
        if (error)
179
                return error;
180 700 simons
_print("%s - %s:%d\n",__FILE__,__FUNCTION__,__LINE__);
181
        error = do_execve(filename, argv, envp, regs);
182
_print("%s - %s:%d\n",__FILE__,__FUNCTION__,__LINE__);
183
        putname(filename);
184 666 simons
#if ICACHE
185
        ic_invalidate();
186
#endif
187 700 simons
_print("%s - %s:%d\n",__FILE__,__FUNCTION__,__LINE__);
188 666 simons
        return error;
189
}

powered by: WebSVN 2.1.0

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