2 * Copyright (C) 2004-2006 Atmel Corporation
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
8 #ifndef __ASM_AVR32_PROCESSOR_H
9 #define __ASM_AVR32_PROCESSOR_H
12 #include <asm/cache.h>
14 #define TASK_SIZE 0x80000000
17 #define STACK_TOP TASK_SIZE
18 #define STACK_TOP_MAX STACK_TOP
23 static inline void *current_text_addr(void)
25 register void *pc
asm("pc");
48 #define AVR32_FEATURE_RMW (1 << 0)
49 #define AVR32_FEATURE_DSP (1 << 1)
50 #define AVR32_FEATURE_SIMD (1 << 2)
51 #define AVR32_FEATURE_OCD (1 << 3)
52 #define AVR32_FEATURE_PCTR (1 << 4)
53 #define AVR32_FEATURE_JAVA (1 << 5)
54 #define AVR32_FEATURE_FPU (1 << 6)
56 struct avr32_cpuinfo
{
58 unsigned long loops_per_jiffy
;
59 enum arch_type arch_type
;
60 enum cpu_type cpu_type
;
61 unsigned short arch_revision
;
62 unsigned short cpu_revision
;
63 enum tlb_config tlb_config
;
64 unsigned long features
;
67 struct cache_info icache
;
68 struct cache_info dcache
;
71 static inline unsigned int avr32_get_manufacturer_id(struct avr32_cpuinfo
*cpu
)
73 return (cpu
->device_id
>> 1) & 0x7f;
75 static inline unsigned int avr32_get_product_number(struct avr32_cpuinfo
*cpu
)
77 return (cpu
->device_id
>> 12) & 0xffff;
79 static inline unsigned int avr32_get_chip_revision(struct avr32_cpuinfo
*cpu
)
81 return (cpu
->device_id
>> 28) & 0x0f;
84 extern struct avr32_cpuinfo boot_cpu_data
;
87 extern struct avr32_cpuinfo cpu_data
[];
88 #define current_cpu_data cpu_data[smp_processor_id()]
90 #define cpu_data (&boot_cpu_data)
91 #define current_cpu_data boot_cpu_data
94 /* This decides where the kernel will search for a free chunk of vm
97 #define TASK_UNMAPPED_BASE (PAGE_ALIGN(TASK_SIZE / 3))
99 #define cpu_relax() barrier()
100 #define cpu_sync_pipeline() asm volatile("sub pc, -2" : : : "memory")
105 unsigned long ksp
; /* Kernel stack pointer */
116 /* This struct contains the CPU context as stored by switch_to() */
117 struct thread_struct
{
118 struct cpu_context cpu_context
;
119 unsigned long single_step_addr
;
120 u16 single_step_insn
;
123 #define INIT_THREAD { \
125 .ksp = sizeof(init_stack) + (long)&init_stack, \
130 * Do necessary setup to start up a newly executed thread.
132 #define start_thread(regs, new_pc, new_sp) \
135 memset(regs, 0, sizeof(*regs)); \
136 regs->sr = MODE_USER; \
137 regs->pc = new_pc & ~1; \
143 /* Free all resources held by a thread */
144 extern void release_thread(struct task_struct
*);
146 /* Create a kernel thread without removing it from tasklists */
147 extern int kernel_thread(int (*fn
)(void *), void *arg
, unsigned long flags
);
149 /* Prepare to copy thread state - unlazy all lazy status */
150 #define prepare_to_copy(tsk) do { } while(0)
152 /* Return saved PC of a blocked thread */
153 #define thread_saved_pc(tsk) ((tsk)->thread.cpu_context.pc)
156 extern unsigned long get_wchan(struct task_struct
*p
);
157 extern void show_regs_log_lvl(struct pt_regs
*regs
, const char *log_lvl
);
158 extern void show_stack_log_lvl(struct task_struct
*tsk
, unsigned long sp
,
159 struct pt_regs
*regs
, const char *log_lvl
);
161 #define task_pt_regs(p) \
162 ((struct pt_regs *)(THREAD_SIZE + task_stack_page(p)) - 1)
164 #define KSTK_EIP(tsk) ((tsk)->thread.cpu_context.pc)
165 #define KSTK_ESP(tsk) ((tsk)->thread.cpu_context.ksp)
167 #define ARCH_HAS_PREFETCH
169 static inline void prefetch(const void *x
)
172 asm volatile("pref %0" : : "r"(c
));
174 #define PREFETCH_STRIDE L1_CACHE_BYTES
176 #endif /* __ASSEMBLY__ */
178 #endif /* __ASM_AVR32_PROCESSOR_H */