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

Subversion Repositories or1k_old

[/] [or1k_old/] [trunk/] [rc203soc/] [sw/] [uClinux/] [arch/] [armnommu/] [kernel/] [process.c] - Blame information for rev 1782

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1622 jcastillo
/*
2
 *  linux/arch/arm/kernel/process.c
3
 *
4
 *  Copyright (C) 1996 Russell King - Converted to ARM.
5
 *  Origional Copyright (C) 1995  Linus Torvalds
6
 */
7
 
8
/*
9
 * This file handles the architecture-dependent parts of process handling..
10
 */
11
 
12
#include <linux/errno.h>
13
#include <linux/sched.h>
14
#include <linux/kernel.h>
15
#include <linux/mm.h>
16
#include <linux/stddef.h>
17
#include <linux/unistd.h>
18
#include <linux/ptrace.h>
19
#include <linux/malloc.h>
20
#include <linux/ldt.h>
21
#include <linux/user.h>
22
#include <linux/a.out.h>
23
 
24
#include <asm/segment.h>
25
#include <asm/pgtable.h>
26
#include <asm/system.h>
27
#include <asm/io.h>
28
 
29
extern void fpe_save(struct fp_soft_struct *);
30
extern char *processor_modes[];
31
 
32
asmlinkage void ret_from_sys_call(void) __asm__("_ret_from_sys_call");
33
 
34
static int hlt_counter = 0;
35
 
36
void disable_hlt(void)
37
{
38
        hlt_counter++;
39
}
40
 
41
void enable_hlt(void)
42
{
43
        hlt_counter--;
44
}
45
 
46
/*
47
 * The idle loop on an arm..
48
 */
49
asmlinkage int sys_idle(void)
50
{
51
        if (current->pid != 0)
52
                return -EPERM;
53
 
54
        /* endless idle loop with no priority at all */
55
        current->counter = -100;
56
        for (;;) {
57
                if (!hlt_counter && !need_resched)
58
                        proc_idle ();
59
                schedule();
60
        }
61
}
62
 
63
void reboot_setup(char *str, int *ints)
64
{
65
}
66
 
67
/*
68
 * This routine reboots the machine by resetting the expansion cards via
69
 * their loaders, turning off the processor cache (if ARM3), copying the
70
 * first instruction of the ROM to 0, and executing it there.
71
 */
72
void hard_reset_now(void)
73
{
74
        proc_hard_reset ();
75
        arch_hard_reset ();
76
}
77
 
78
void show_regs(struct pt_regs * regs)
79
{
80
        unsigned long flags;
81
 
82
        flags = condition_codes(regs);
83
 
84
        printk("\n"
85
                "pc : [<%08lx>]\n"
86
                "lr : [<%08lx>]\n"
87
                "sp : %08lx  ip : %08lx  fp : %08lx\n",
88
                instruction_pointer(regs),
89
                regs->ARM_lr,
90
                regs->ARM_sp,
91
                regs->ARM_ip,
92
                regs->ARM_fp);
93
        printk( "r10: %08lx  r9 : %08lx  r8 : %08lx\n",
94
                regs->ARM_r10,
95
                regs->ARM_r9,
96
                regs->ARM_r8);
97
        printk( "r7 : %08lx  r6 : %08lx  r5 : %08lx  r4 : %08lx\n",
98
                regs->ARM_r7,
99
                regs->ARM_r6,
100
                regs->ARM_r5,
101
                regs->ARM_r4);
102
        printk( "r3 : %08lx  r2 : %08lx  r1 : %08lx  r0 : %08lx\n",
103
                regs->ARM_r3,
104
                regs->ARM_r2,
105
                regs->ARM_r1,
106
                regs->ARM_r0);
107
        printk("Flags: %c%c%c%c",
108
                flags & CC_N_BIT ? 'N' : 'n',
109
                flags & CC_Z_BIT ? 'Z' : 'z',
110
                flags & CC_C_BIT ? 'C' : 'c',
111
                flags & CC_V_BIT ? 'V' : 'v');
112
        printk("  IRQs %s  FIQs %s  Mode %s\n",
113
                interrupts_enabled(regs) ? "on" : "off",
114
                fast_interrupts_enabled(regs) ? "on" : "off",
115
                processor_modes[processor_mode(regs)]);
116
}
117
 
118
/*
119
 * Free current thread data structures etc..
120
 */
121
void exit_thread (void)
122
{
123
        if (last_task_used_math == current)
124
                last_task_used_math = NULL;
125
}
126
 
127
void flush_thread(void)
128
{
129
        int i;
130
 
131
        for (i = 0; i < 8; i++)
132
                current->debugreg[i] = 0;
133
        if (last_task_used_math == current)
134
                last_task_used_math = NULL;
135
        current->tss.fs = USER_DS;
136
}
137
 
138
void release_thread(struct task_struct *dead_task)
139
{
140
}
141
 
142
void copy_thread(int nr, unsigned long clone_flags, unsigned long esp,
143
        struct task_struct * p, struct pt_regs * regs)
144
{
145
        struct pt_regs * childregs;
146
        struct context_save_struct * save;
147
 
148
        childregs = ((struct pt_regs *)(p->kernel_stack_page + 4096)) - 1;
149
        *childregs = *regs;
150
        childregs->ARM_r0 = 0;
151
 
152
        save = ((struct context_save_struct *)(childregs)) - 1;
153
        copy_thread_css (save);
154
        p->tss.save = save;
155
        /*
156
         * Save current math state in p->tss.fpe_save if not already there.
157
         */
158
        if (last_task_used_math == current)
159
                fpe_save (&p->tss.fpstate.soft);
160
}
161
 
162
/*
163
 * fill in the fpe structure for a core dump...
164
 */
165
int dump_fpu (struct pt_regs *regs, struct user_fp *fp)
166
{
167
        int fpvalid = 0;
168
 
169
        if (current->used_math) {
170
                if (last_task_used_math == current)
171
                        fpe_save (&current->tss.fpstate.soft);
172
 
173
                memcpy (fp, &current->tss.fpstate.soft, sizeof (fp));
174
        }
175
 
176
        return fpvalid;
177
}
178
 
179
/*
180
 * fill in the user structure for a core dump..
181
 */
182
void dump_thread(struct pt_regs * regs, struct user * dump)
183
{
184
        int i;
185
 
186
        dump->magic = CMAGIC;
187
        dump->start_code = current->mm->start_code;
188
        dump->start_stack = regs->ARM_sp & ~(PAGE_SIZE - 1);
189
 
190
        dump->u_tsize = (current->mm->end_code - current->mm->start_code) >> PAGE_SHIFT;
191
        dump->u_dsize = (current->mm->brk - current->mm->start_data + PAGE_SIZE - 1) >> PAGE_SHIFT;
192
        dump->u_ssize = 0;
193
 
194
        for (i = 0; i < 8; i++)
195
                dump->u_debugreg[i] = current->debugreg[i];
196
 
197
        if (dump->start_stack < 0x04000000)
198
                dump->u_ssize = (0x04000000 - dump->start_stack) >> PAGE_SHIFT;
199
 
200
        dump->regs = *regs;
201
        dump->u_fpvalid = dump_fpu (regs, &dump->u_fp);
202
}
203
 
204
asmlinkage int sys_fork(void)
205
{
206
        struct pt_regs *regs;
207
        __asm__("mov\t%0, r9\n\t": "=r" (regs) );
208
 
209
        return do_fork(SIGCHLD, regs->ARM_sp, regs);
210
}
211
 
212
asmlinkage int sys_clone(unsigned long clone_flags, unsigned long newsp)
213
{
214
        struct pt_regs *regs;
215
        __asm__("mov\t%0, r9\n\t":"=r" (regs) );
216
        if (!newsp)
217
                newsp = regs->ARM_sp;
218
 
219
        return do_fork(clone_flags, newsp, regs);
220
}
221
 
222
/*
223
 * sys_execve() executes a new program.
224
 */
225
asmlinkage int sys_execve(char *filenamei, char **argv, char **envp)
226
{
227
        int error;
228
        char * filename;
229
        struct pt_regs *regs;
230
        /*
231
         * I hate this type of thing.  Oh well.
232
         * I can't guarantee any way of getting the registers efficiently
233
         */
234
        __asm__("mov\t%0, r9\n\t": "=r" (regs));
235
        error = getname(filenamei, &filename);
236
        if (error)
237
                return error;
238
        error = do_execve(filename, argv, envp, regs);
239
        putname(filename);
240
        return error;
241
}

powered by: WebSVN 2.1.0

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