#include <linux/interrupt.h>
#include <linux/kallsyms.h>
#include <linux/init.h>
+#include <linux/cpu.h>
+#include <linux/elfcore.h>
-#include <asm/system.h>
-#include <asm/io.h>
#include <asm/leds.h>
#include <asm/processor.h>
+#include <asm/system.h>
#include <asm/uaccess.h>
+#include <asm/mach/time.h>
extern const char *processor_modes[];
extern void setup_mm_for_reboot(char mode);
* The following aren't currently used.
*/
void (*pm_idle)(void);
+EXPORT_SYMBOL(pm_idle);
+
void (*pm_power_off)(void);
+EXPORT_SYMBOL(pm_power_off);
/*
* This is our default idle handler. We need to disable
* interrupts here to ensure we don't miss a wakeup call.
*/
-void default_idle(void)
+static void default_idle(void)
{
- local_irq_disable();
- if (!need_resched() && !hlt_counter)
- arch_idle();
- local_irq_enable();
+ if (hlt_counter)
+ cpu_relax();
+ else {
+ local_irq_disable();
+ if (!need_resched()) {
+ timer_dyn_reprogram();
+ arch_idle();
+ }
+ local_irq_enable();
+ }
}
/*
*/
void cpu_idle(void)
{
+ local_fiq_enable();
+
/* endless idle loop with no priority at all */
while (1) {
void (*idle)(void) = pm_idle;
+
+#ifdef CONFIG_HOTPLUG_CPU
+ if (cpu_is_offline(smp_processor_id())) {
+ leds_event(led_idle_start);
+ cpu_die();
+ }
+#endif
+
if (!idle)
idle = default_idle;
- preempt_disable();
leds_event(led_idle_start);
while (!need_resched())
idle();
leds_event(led_idle_end);
- preempt_enable();
+ preempt_enable_no_resched();
schedule();
+ preempt_disable();
}
}
{
}
-EXPORT_SYMBOL(machine_halt);
void machine_power_off(void)
{
pm_power_off();
}
-EXPORT_SYMBOL(machine_power_off);
void machine_restart(char * __unused)
{
while (1);
}
-EXPORT_SYMBOL(machine_restart);
-
-void show_regs(struct pt_regs * regs)
+void __show_regs(struct pt_regs *regs)
{
- unsigned long flags;
-
- flags = condition_codes(regs);
+ unsigned long flags = condition_codes(regs);
+ printk("CPU: %d\n", smp_processor_id());
print_symbol("PC is at %s\n", instruction_pointer(regs));
print_symbol("LR is at %s\n", regs->ARM_lr);
printk("pc : [<%08lx>] lr : [<%08lx>] %s\n"
}
}
+void show_regs(struct pt_regs * regs)
+{
+ printk("\n");
+ printk("Pid: %d, comm: %20s\n", current->pid, current->comm);
+ __show_regs(regs);
+ __backtrace();
+}
+
void show_fpregs(struct user_fp *regs)
{
int i;
/*
* Task structure and kernel stack allocation.
*/
-static unsigned long *thread_info_head;
-static unsigned int nr_thread_info;
+struct thread_info_list {
+ unsigned long *head;
+ unsigned int nr;
+};
+
+static DEFINE_PER_CPU(struct thread_info_list, thread_info_list) = { NULL, 0 };
#define EXTRA_TASK_STRUCT 4
-#define ll_alloc_task_struct() ((struct thread_info *) __get_free_pages(GFP_KERNEL,1))
-#define ll_free_task_struct(p) free_pages((unsigned long)(p),1)
struct thread_info *alloc_thread_info(struct task_struct *task)
{
struct thread_info *thread = NULL;
if (EXTRA_TASK_STRUCT) {
- unsigned long *p = thread_info_head;
+ struct thread_info_list *th = &get_cpu_var(thread_info_list);
+ unsigned long *p = th->head;
if (p) {
- thread_info_head = (unsigned long *)p[0];
- nr_thread_info -= 1;
+ th->head = (unsigned long *)p[0];
+ th->nr -= 1;
}
+ put_cpu_var(thread_info_list);
+
thread = (struct thread_info *)p;
}
if (!thread)
- thread = ll_alloc_task_struct();
+ thread = (struct thread_info *)
+ __get_free_pages(GFP_KERNEL, THREAD_SIZE_ORDER);
-#ifdef CONFIG_MAGIC_SYSRQ
+#ifdef CONFIG_DEBUG_STACK_USAGE
/*
* The stack must be cleared if you want SYSRQ-T to
* give sensible stack usage information
*/
- if (thread) {
- char *p = (char *)thread;
- memzero(p+KERNEL_STACK_SIZE, KERNEL_STACK_SIZE);
- }
+ if (thread)
+ memzero(thread, THREAD_SIZE);
#endif
return thread;
}
void free_thread_info(struct thread_info *thread)
{
- if (EXTRA_TASK_STRUCT && nr_thread_info < EXTRA_TASK_STRUCT) {
- unsigned long *p = (unsigned long *)thread;
- p[0] = (unsigned long)thread_info_head;
- thread_info_head = p;
- nr_thread_info += 1;
- } else
- ll_free_task_struct(thread);
+ if (EXTRA_TASK_STRUCT) {
+ struct thread_info_list *th = &get_cpu_var(thread_info_list);
+ if (th->nr < EXTRA_TASK_STRUCT) {
+ unsigned long *p = (unsigned long *)thread;
+ p[0] = (unsigned long)th->head;
+ th->head = p;
+ th->nr += 1;
+ put_cpu_var(thread_info_list);
+ return;
+ }
+ put_cpu_var(thread_info_list);
+ }
+ free_pages((unsigned long)thread, THREAD_SIZE_ORDER);
}
/*
}
void (*fp_init)(union fp_state *) = default_fp_init;
+EXPORT_SYMBOL(fp_init);
void flush_thread(void)
{
memset(thread->used_cp, 0, sizeof(thread->used_cp));
memset(&tsk->thread.debug, 0, sizeof(struct debug_info));
+#if defined(CONFIG_IWMMXT)
+ iwmmxt_task_release(thread);
+#endif
fp_init(&thread->fpstate);
+#if defined(CONFIG_VFP)
+ vfp_flush_thread(&thread->vfpstate);
+#endif
}
void release_thread(struct task_struct *dead_task)
{
+#if defined(CONFIG_VFP)
+ vfp_release_thread(&task_thread_info(dead_task)->vfpstate);
+#endif
+#if defined(CONFIG_IWMMXT)
+ iwmmxt_task_release(task_thread_info(dead_task));
+#endif
}
asmlinkage void ret_from_fork(void) __asm__("ret_from_fork");
copy_thread(int nr, unsigned long clone_flags, unsigned long stack_start,
unsigned long stk_sz, struct task_struct *p, struct pt_regs *regs)
{
- struct thread_info *thread = p->thread_info;
- struct pt_regs *childregs;
+ struct thread_info *thread = task_thread_info(p);
+ struct pt_regs *childregs = task_pt_regs(p);
- childregs = ((struct pt_regs *)((unsigned long)thread + THREAD_SIZE - 8)) - 1;
*childregs = *regs;
childregs->ARM_r0 = 0;
childregs->ARM_sp = stack_start;
thread->cpu_context.sp = (unsigned long)childregs;
thread->cpu_context.pc = (unsigned long)ret_from_fork;
+ if (clone_flags & CLONE_SETTLS)
+ thread->tp_value = regs->ARM_r3;
+
return 0;
}
return used_math != 0;
}
+EXPORT_SYMBOL(dump_fpu);
/*
* fill in the user structure for a core dump..
dump->regs = *regs;
dump->u_fpvalid = dump_fpu (regs, &dump->u_fp);
}
+EXPORT_SYMBOL(dump_thread);
/*
* Shuffle the argument into the correct register before calling the
* the thread function, and r3 points to the exit function.
*/
extern void kernel_thread_helper(void);
-asm( ".align\n"
+asm( ".section .text\n"
+" .align\n"
" .type kernel_thread_helper, #function\n"
"kernel_thread_helper:\n"
" mov r0, r1\n"
" mov lr, r3\n"
" mov pc, r2\n"
-" .size kernel_thread_helper, . - kernel_thread_helper");
+" .size kernel_thread_helper, . - kernel_thread_helper\n"
+" .previous");
/*
* Create a kernel thread.
return do_fork(flags|CLONE_VM|CLONE_UNTRACED, 0, ®s, 0, NULL, NULL);
}
-
-/*
- * These bracket the sleeping functions..
- */
-#define first_sched ((unsigned long) scheduling_functions_start_here)
-#define last_sched ((unsigned long) scheduling_functions_end_here)
+EXPORT_SYMBOL(kernel_thread);
unsigned long get_wchan(struct task_struct *p)
{
unsigned long fp, lr;
- unsigned long stack_page;
+ unsigned long stack_start, stack_end;
int count = 0;
if (!p || p == current || p->state == TASK_RUNNING)
return 0;
- stack_page = 4096 + (unsigned long)p->thread_info;
+ stack_start = (unsigned long)end_of_stack(p);
+ stack_end = (unsigned long)task_stack_page(p) + THREAD_SIZE;
+
fp = thread_saved_fp(p);
do {
- if (fp < stack_page || fp > 4092+stack_page)
+ if (fp < stack_start || fp > stack_end)
return 0;
lr = pc_pointer (((unsigned long *)fp)[-1]);
- if (lr < first_sched || lr > last_sched)
+ if (!in_sched_functions(lr))
return lr;
fp = *(unsigned long *) (fp - 12);
} while (count ++ < 16);