~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/cris/arch-v10/kernel/process.c

Version: ~ [ linux-5.12-rc1 ] ~ [ linux-5.11.2 ] ~ [ linux-5.10.19 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.101 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.177 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.222 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.258 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.258 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.18.140 ] ~ [ linux-3.16.85 ] ~ [ linux-3.14.79 ] ~ [ linux-3.12.74 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /*
  2  *  linux/arch/cris/kernel/process.c
  3  *
  4  *  Copyright (C) 1995  Linus Torvalds
  5  *  Copyright (C) 2000-2002  Axis Communications AB
  6  *
  7  *  Authors:   Bjorn Wesen (bjornw@axis.com)
  8  *             Mikael Starvik (starvik@axis.com)
  9  *
 10  * This file handles the architecture-dependent parts of process handling..
 11  */
 12 
 13 #include <linux/sched.h>
 14 #include <linux/slab.h>
 15 #include <linux/err.h>
 16 #include <linux/fs.h>
 17 #include <arch/svinto.h>
 18 #include <linux/init.h>
 19 #include <arch/system.h>
 20 #include <linux/ptrace.h>
 21 
 22 #ifdef CONFIG_ETRAX_GPIO
 23 void etrax_gpio_wake_up_check(void); /* drivers/gpio.c */
 24 #endif
 25 
 26 /*
 27  * We use this if we don't have any better
 28  * idle routine..
 29  */
 30 void default_idle(void)
 31 {
 32 #ifdef CONFIG_ETRAX_GPIO
 33         etrax_gpio_wake_up_check();
 34 #endif
 35         local_irq_enable();
 36 }
 37 
 38 /* if the watchdog is enabled, we can simply disable interrupts and go
 39  * into an eternal loop, and the watchdog will reset the CPU after 0.1s
 40  * if on the other hand the watchdog wasn't enabled, we just enable it and wait
 41  */
 42 
 43 void hard_reset_now (void)
 44 {
 45         /*
 46          * Don't declare this variable elsewhere.  We don't want any other
 47          * code to know about it than the watchdog handler in entry.S and
 48          * this code, implementing hard reset through the watchdog.
 49          */
 50 #if defined(CONFIG_ETRAX_WATCHDOG)
 51         extern int cause_of_death;
 52 #endif
 53 
 54         printk("*** HARD RESET ***\n");
 55         local_irq_disable();
 56 
 57 #if defined(CONFIG_ETRAX_WATCHDOG)
 58         cause_of_death = 0xbedead;
 59 #else
 60         /* Since we dont plan to keep on resetting the watchdog,
 61            the key can be arbitrary hence three */
 62         *R_WATCHDOG = IO_FIELD(R_WATCHDOG, key, 3) |
 63                 IO_STATE(R_WATCHDOG, enable, start);
 64 #endif
 65 
 66         while(1) /* waiting for RETRIBUTION! */ ;
 67 }
 68 
 69 /*
 70  * Return saved PC of a blocked thread.
 71  */
 72 unsigned long thread_saved_pc(struct task_struct *t)
 73 {
 74         return task_pt_regs(t)->irp;
 75 }
 76 
 77 /* setup the child's kernel stack with a pt_regs and switch_stack on it.
 78  * it will be un-nested during _resume and _ret_from_sys_call when the
 79  * new thread is scheduled.
 80  *
 81  * also setup the thread switching structure which is used to keep
 82  * thread-specific data during _resumes.
 83  *
 84  */
 85 asmlinkage void ret_from_fork(void);
 86 asmlinkage void ret_from_kernel_thread(void);
 87 
 88 int copy_thread(unsigned long clone_flags, unsigned long usp,
 89                 unsigned long arg, struct task_struct *p)
 90 {
 91         struct pt_regs *childregs = task_pt_regs(p);
 92         struct switch_stack *swstack = ((struct switch_stack *)childregs) - 1;
 93         
 94         /* put the pt_regs structure at the end of the new kernel stack page and fix it up
 95          * remember that the task_struct doubles as the kernel stack for the task
 96          */
 97 
 98         if (unlikely(p->flags & PF_KTHREAD)) {
 99                 memset(swstack, 0,
100                         sizeof(struct switch_stack) + sizeof(struct pt_regs));
101                 swstack->r1 = usp;
102                 swstack->r2 = arg;
103                 childregs->dccr = 1 << I_DCCR_BITNR;
104                 swstack->return_ip = (unsigned long) ret_from_kernel_thread;
105                 p->thread.ksp = (unsigned long) swstack;
106                 p->thread.usp = 0;
107                 return 0;
108         }
109         *childregs = *current_pt_regs();  /* struct copy of pt_regs */
110 
111         childregs->r10 = 0;  /* child returns 0 after a fork/clone */
112 
113         /* put the switch stack right below the pt_regs */
114 
115         swstack->r9 = 0; /* parameter to ret_from_sys_call, 0 == dont restart the syscall */
116 
117         /* we want to return into ret_from_sys_call after the _resume */
118 
119         swstack->return_ip = (unsigned long) ret_from_fork; /* Will call ret_from_sys_call */
120         
121         /* fix the user-mode stackpointer */
122 
123         p->thread.usp = usp ?: rdusp();
124 
125         /* and the kernel-mode one */
126 
127         p->thread.ksp = (unsigned long) swstack;
128 
129 #ifdef DEBUG
130         printk("copy_thread: new regs at 0x%p, as shown below:\n", childregs);
131         show_registers(childregs);
132 #endif
133 
134         return 0;
135 }
136 
137 unsigned long get_wchan(struct task_struct *p)
138 {
139 #if 0
140         /* YURGH. TODO. */
141 
142         unsigned long ebp, esp, eip;
143         unsigned long stack_page;
144         int count = 0;
145         if (!p || p == current || p->state == TASK_RUNNING)
146                 return 0;
147         stack_page = (unsigned long)p;
148         esp = p->thread.esp;
149         if (!stack_page || esp < stack_page || esp > 8188+stack_page)
150                 return 0;
151         /* include/asm-i386/system.h:switch_to() pushes ebp last. */
152         ebp = *(unsigned long *) esp;
153         do {
154                 if (ebp < stack_page || ebp > 8184+stack_page)
155                         return 0;
156                 eip = *(unsigned long *) (ebp+4);
157                 if (!in_sched_functions(eip))
158                         return eip;
159                 ebp = *(unsigned long *) ebp;
160         } while (count++ < 16);
161 #endif
162         return 0;
163 }
164 #undef last_sched
165 #undef first_sched
166 
167 void show_regs(struct pt_regs * regs)
168 {
169         unsigned long usp = rdusp();
170 
171         show_regs_print_info(KERN_DEFAULT);
172 
173         printk("IRP: %08lx SRP: %08lx DCCR: %08lx USP: %08lx MOF: %08lx\n",
174                regs->irp, regs->srp, regs->dccr, usp, regs->mof );
175         printk(" r0: %08lx  r1: %08lx   r2: %08lx  r3: %08lx\n",
176                regs->r0, regs->r1, regs->r2, regs->r3);
177         printk(" r4: %08lx  r5: %08lx   r6: %08lx  r7: %08lx\n",
178                regs->r4, regs->r5, regs->r6, regs->r7);
179         printk(" r8: %08lx  r9: %08lx  r10: %08lx r11: %08lx\n",
180                regs->r8, regs->r9, regs->r10, regs->r11);
181         printk("r12: %08lx r13: %08lx oR10: %08lx\n",
182                regs->r12, regs->r13, regs->orig_r10);
183 }
184 
185 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp