2 * Copyright (C) 2006 Atmel Corporation
4 * See file CREDITS for list of people who contributed to this
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of
10 * the License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
22 #ifndef __ASM_AVR32_PROCESSOR_H
23 #define __ASM_AVR32_PROCESSOR_H
27 #define current_text_addr() ({ void *pc; __asm__("mov %0,pc" : "=r"(pc)); pc; })
29 struct avr32_cpuinfo {
30 unsigned long loops_per_jiffy;
33 extern struct avr32_cpuinfo boot_cpu_data;
36 extern struct avr32_cpuinfo cpu_data[];
37 #define current_cpu_data cpu_data[smp_processor_id()]
39 #define cpu_data (&boot_cpu_data)
40 #define current_cpu_data boot_cpu_data
43 /* TODO: Make configurable (2GB will serve as a reasonable default) */
44 #define TASK_SIZE 0x80000000
46 /* This decides where the kernel will search for a free chunk of vm
49 #define TASK_UNMAPPED_BASE (TASK_SIZE / 3)
51 #define cpu_relax() barrier()
52 #define cpu_sync_pipeline() asm volatile("sub pc, -2" : : : "memory")
54 /* This struct contains the CPU context as stored by switch_to() */
55 struct thread_struct {
57 unsigned long ksp; /* Kernel stack pointer */
68 #define INIT_THREAD { \
69 .ksp = sizeof(init_stack) + (long)&init_stack, \
73 * Do necessary setup to start up a newly executed thread.
75 #define start_thread(regs, new_pc, new_sp) \
77 regs->sr = 0; /* User mode. */ \
78 regs->gr[REG_PC] = new_pc; \
79 regs->gr[REG_SP] = new_sp
83 /* Free all resources held by a thread */
84 extern void release_thread(struct task_struct *);
86 /* Create a kernel thread without removing it from tasklists */
87 extern int kernel_thread(int (*fn)(void *), void *arg, unsigned long flags);
89 /* Prepare to copy thread state - unlazy all lazy status */
90 #define prepare_to_copy(tsk) do { } while(0)
92 /* Return saved PC of a blocked thread */
93 #define thread_saved_pc(tsk) (tsk->thread.pc)
95 #endif /* __ASSEMBLY__ */
97 #endif /* __ASM_AVR32_PROCESSOR_H */