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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rc203soc/] [sw/] [uClinux/] [arch/] [m68knommu/] [kernel/] [process.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1625 jcastillo
/*
2
 *  linux/arch/m68knommu/kernel/process.c
3
 *
4
 *  Copyright (C) 1998  D. Jeff Dionne <jeff@ryeham.ee.ryerson.ca>,
5
 *                      Kenneth Albanowski <kjahds@kjahds.com>,
6
 *                      The Silver Hammer Group, Ltd.
7
 *
8
 *  Based on:
9
 *
10
 *  linux/arch/m68k/kernel/process.c
11
 *
12
 *  Copyright (C) 1995  Hamish Macdonald
13
 *
14
 *  68060 fixes by Jesper Skov
15
 */
16
 
17
/*
18
 * This file handles the architecture-dependent parts of process handling..
19
 */
20
 
21
#include <linux/config.h>
22
#include <linux/errno.h>
23
#include <linux/sched.h>
24
#include <linux/kernel.h>
25
#include <linux/mm.h>
26
#include <linux/stddef.h>
27
#include <linux/unistd.h>
28
#include <linux/ptrace.h>
29
#include <linux/malloc.h>
30
#include <linux/user.h>
31
#include <linux/a.out.h>
32
 
33
#include <asm/segment.h>
34
#include <asm/system.h>
35
#include <asm/traps.h>
36
#include <asm/machdep.h>
37
#include <asm/setup.h>
38
 
39
asmlinkage void ret_from_exception(void);
40
 
41
/*
42
 * The idle loop on an m68k..
43
 */
44
asmlinkage int sys_idle(void)
45
{
46
        if (current->pid != 0)
47
                return -EPERM;
48
 
49
 
50
        /* endless idle loop with no priority at all */
51
        current->counter = -100;
52
        for (;;) {
53
#ifdef CONFIG_SHGLCORE
54
                *(volatile unsigned char *)0xfffa13 &= 0x7f;   /* turn on the LED */
55
#endif
56
#ifdef CONFIG_UCSIMM
57
                *(volatile unsigned char *)0xfffff207 = 0xc0; /* idle the cpu */
58
#endif
59
 
60
                schedule();
61
        }
62
}
63
 
64
void hard_reset_now(void)
65
{
66
        HARD_RESET_NOW();
67
}
68
 
69
void show_regs(struct pt_regs * regs)
70
{
71
        printk("\n");
72
        printk("Format %02x  Vector: %04x  PC: %08lx  Status: %04x\n",
73
               regs->format, regs->vector, regs->pc, regs->sr);
74
        printk("ORIG_D0: %08lx  D0: %08lx  A1: %08lx\n",
75
               regs->orig_d0, regs->d0, regs->a1);
76
        printk("A0: %08lx  D5: %08lx  D4: %08lx\n",
77
               regs->a0, regs->d5, regs->d4);
78
        printk("D3: %08lx  D2: %08lx  D1: %08lx\n",
79
               regs->d3, regs->d2, regs->d1);
80
        if (!(regs->sr & PS_S))
81
                printk("USP: %08lx\n", rdusp());
82
}
83
 
84
/*
85
 * Free current thread data structures etc..
86
 */
87
void exit_thread(void)
88
{
89
}
90
 
91
void flush_thread(void)
92
{
93
        set_fs(USER_DS);
94
        current->tss.fs = USER_DS;
95
}
96
 
97
/*
98
 * "m68k_fork()".. By the time we get here, the
99
 * non-volatile registers have also been saved on the
100
 * stack. We do some ugly pointer stuff here.. (see
101
 * also copy_thread)
102
 */
103
 
104
asmlinkage int m68k_fork(struct pt_regs *regs)
105
{
106
        return do_fork(SIGCHLD|CLONE_WAIT, rdusp(), regs);
107
}
108
 
109
asmlinkage int m68k_clone(struct pt_regs *regs)
110
{
111
        unsigned long clone_flags;
112
        unsigned long newsp;
113
 
114
        /* syscall2 puts clone_flags in d1 and usp in d2 */
115
        clone_flags = regs->d1;
116
        newsp = regs->d2;
117
        if (!newsp)
118
          newsp  = rdusp();
119
        return do_fork(clone_flags, newsp, regs);
120
}
121
 
122
void release_thread(struct task_struct *dead_task)
123
{
124
}
125
 
126
void copy_thread(int nr, unsigned long clone_flags, unsigned long usp,
127
                 struct task_struct * p, struct pt_regs * regs)
128
{
129
        struct pt_regs * childregs;
130
        struct switch_stack * childstack, *stack;
131
        unsigned long stack_offset, *retp;
132
 
133
        stack_offset = PAGE_SIZE - sizeof(struct pt_regs);
134
        childregs = (struct pt_regs *) (p->kernel_stack_page + stack_offset);
135
 
136
        *childregs = *regs;
137
        childregs->d0 = 0;
138
 
139
        retp = ((unsigned long *) regs);
140
        stack = ((struct switch_stack *) retp) - 1;
141
 
142
        childstack = ((struct switch_stack *) childregs) - 1;
143
        *childstack = *stack;
144
        childstack->retpc = (unsigned long) ret_from_exception;
145
 
146
        p->tss.usp = usp;
147
        p->tss.ksp = (unsigned long)childstack;
148
        /*
149
         * Must save the current SFC/DFC value, NOT the value when
150
         * the parent was last descheduled - RGH  10-08-96
151
         */
152
        p->tss.fs = get_fs();
153
 
154
#ifndef NO_FPU
155
        /* Copy the current fpu state */
156
        asm volatile ("fsave %0" : : "m" (p->tss.fpstate[0]) : "memory");
157
 
158
        if((!CPU_IS_060 && p->tss.fpstate[0]) ||
159
           (CPU_IS_060 && p->tss.fpstate[2]))
160
          asm volatile ("fmovemx %/fp0-%/fp7,%0\n\t"
161
                        "fmoveml %/fpiar/%/fpcr/%/fpsr,%1"
162
                        : : "m" (p->tss.fp[0]), "m" (p->tss.fpcntl[0])
163
                        : "memory");
164
        /* Restore the state in case the fpu was busy */
165
        asm volatile ("frestore %0" : : "m" (p->tss.fpstate[0]));
166
#endif
167
}
168
 
169
/* Fill in the fpu structure for a core dump.  */
170
 
171
int dump_fpu (struct pt_regs *regs, struct user_m68kfp_struct *fpu)
172
{
173
  return 0;
174
}
175
 
176
/*
177
 * fill in the user structure for a core dump..
178
 */
179
void dump_thread(struct pt_regs * regs, struct user * dump)
180
{
181
/* changed the size calculations - should hopefully work better. lbt */
182
        dump->magic = CMAGIC;
183
        dump->start_code = 0;
184
        dump->start_stack = rdusp() & ~(PAGE_SIZE - 1);
185
        dump->u_tsize = ((unsigned long) current->mm->end_code) >> PAGE_SHIFT;
186
        dump->u_dsize = ((unsigned long) (current->mm->brk +
187
                                          (PAGE_SIZE-1))) >> PAGE_SHIFT;
188
        dump->u_dsize -= dump->u_tsize;
189
        dump->u_ssize = 0;
190
 
191
 
192
        /* FIXME */
193
        /*if (dump->start_stack < TASK_SIZE)
194
                dump->u_ssize = ((unsigned long) (TASK_SIZE - dump->start_stack)) >> PAGE_SHIFT;*/
195
 
196
        dump->u_ar0 = (struct pt_regs *)(((int)(&dump->regs)) -((int)(dump)));
197
        dump->regs = *regs;
198
        dump->regs2 = ((struct switch_stack *)regs)[-1];
199
        /* dump floating point stuff */
200
        dump->u_fpvalid = dump_fpu (regs, &dump->m68kfp);
201
}
202
 
203
/*
204
 * sys_execve() executes a new program.
205
 */
206
asmlinkage int sys_execve(char *name, char **argv, char **envp)
207
{
208
        int error;
209
        char * filename;
210
        struct pt_regs *regs = (struct pt_regs *) &name;
211
 
212
        error = getname(name, &filename);
213
        if (error)
214
                return error;
215
        error = do_execve(filename, argv, envp, regs);
216
        putname(filename);
217
        return error;
218
}

powered by: WebSVN 2.1.0

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