]>
Commit | Line | Data |
---|---|---|
5f97f7f9 HS |
1 | /* |
2 | * Copyright (C) 2004-2006 Atmel Corporation | |
3 | * | |
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. | |
7 | */ | |
8 | #ifndef __ASM_AVR32_PROCESSOR_H | |
9 | #define __ASM_AVR32_PROCESSOR_H | |
10 | ||
11 | #include <asm/page.h> | |
12 | #include <asm/cache.h> | |
13 | ||
14 | #define TASK_SIZE 0x80000000 | |
15 | ||
16 | #ifndef __ASSEMBLY__ | |
17 | ||
18 | static inline void *current_text_addr(void) | |
19 | { | |
20 | register void *pc asm("pc"); | |
21 | return pc; | |
22 | } | |
23 | ||
24 | enum arch_type { | |
25 | ARCH_AVR32A, | |
26 | ARCH_AVR32B, | |
27 | ARCH_MAX | |
28 | }; | |
29 | ||
30 | enum cpu_type { | |
31 | CPU_MORGAN, | |
32 | CPU_AT32AP, | |
33 | CPU_MAX | |
34 | }; | |
35 | ||
36 | enum tlb_config { | |
37 | TLB_NONE, | |
38 | TLB_SPLIT, | |
39 | TLB_UNIFIED, | |
40 | TLB_INVALID | |
41 | }; | |
42 | ||
3b328c98 HS |
43 | #define AVR32_FEATURE_RMW (1 << 0) |
44 | #define AVR32_FEATURE_DSP (1 << 1) | |
45 | #define AVR32_FEATURE_SIMD (1 << 2) | |
46 | #define AVR32_FEATURE_OCD (1 << 3) | |
47 | #define AVR32_FEATURE_PCTR (1 << 4) | |
48 | #define AVR32_FEATURE_JAVA (1 << 5) | |
49 | #define AVR32_FEATURE_FPU (1 << 6) | |
50 | ||
5f97f7f9 HS |
51 | struct avr32_cpuinfo { |
52 | struct clk *clk; | |
53 | unsigned long loops_per_jiffy; | |
54 | enum arch_type arch_type; | |
55 | enum cpu_type cpu_type; | |
56 | unsigned short arch_revision; | |
57 | unsigned short cpu_revision; | |
58 | enum tlb_config tlb_config; | |
3b328c98 | 59 | unsigned long features; |
281ef58c | 60 | u32 device_id; |
5f97f7f9 HS |
61 | |
62 | struct cache_info icache; | |
63 | struct cache_info dcache; | |
64 | }; | |
65 | ||
281ef58c HS |
66 | static inline unsigned int avr32_get_manufacturer_id(struct avr32_cpuinfo *cpu) |
67 | { | |
68 | return (cpu->device_id >> 1) & 0x7f; | |
69 | } | |
70 | static inline unsigned int avr32_get_product_number(struct avr32_cpuinfo *cpu) | |
71 | { | |
72 | return (cpu->device_id >> 12) & 0xffff; | |
73 | } | |
74 | static inline unsigned int avr32_get_chip_revision(struct avr32_cpuinfo *cpu) | |
75 | { | |
76 | return (cpu->device_id >> 28) & 0x0f; | |
77 | } | |
78 | ||
5f97f7f9 HS |
79 | extern struct avr32_cpuinfo boot_cpu_data; |
80 | ||
81 | #ifdef CONFIG_SMP | |
82 | extern struct avr32_cpuinfo cpu_data[]; | |
83 | #define current_cpu_data cpu_data[smp_processor_id()] | |
84 | #else | |
85 | #define cpu_data (&boot_cpu_data) | |
86 | #define current_cpu_data boot_cpu_data | |
87 | #endif | |
88 | ||
89 | /* This decides where the kernel will search for a free chunk of vm | |
90 | * space during mmap's | |
91 | */ | |
92 | #define TASK_UNMAPPED_BASE (PAGE_ALIGN(TASK_SIZE / 3)) | |
93 | ||
94 | #define cpu_relax() barrier() | |
95 | #define cpu_sync_pipeline() asm volatile("sub pc, -2" : : : "memory") | |
96 | ||
97 | struct cpu_context { | |
98 | unsigned long sr; | |
99 | unsigned long pc; | |
100 | unsigned long ksp; /* Kernel stack pointer */ | |
101 | unsigned long r7; | |
102 | unsigned long r6; | |
103 | unsigned long r5; | |
104 | unsigned long r4; | |
105 | unsigned long r3; | |
106 | unsigned long r2; | |
107 | unsigned long r1; | |
108 | unsigned long r0; | |
109 | }; | |
110 | ||
111 | /* This struct contains the CPU context as stored by switch_to() */ | |
112 | struct thread_struct { | |
113 | struct cpu_context cpu_context; | |
114 | unsigned long single_step_addr; | |
115 | u16 single_step_insn; | |
116 | }; | |
117 | ||
118 | #define INIT_THREAD { \ | |
119 | .cpu_context = { \ | |
120 | .ksp = sizeof(init_stack) + (long)&init_stack, \ | |
121 | }, \ | |
122 | } | |
123 | ||
124 | /* | |
125 | * Do necessary setup to start up a newly executed thread. | |
126 | */ | |
127 | #define start_thread(regs, new_pc, new_sp) \ | |
128 | do { \ | |
129 | set_fs(USER_DS); \ | |
130 | memset(regs, 0, sizeof(*regs)); \ | |
131 | regs->sr = MODE_USER; \ | |
132 | regs->pc = new_pc & ~1; \ | |
133 | regs->sp = new_sp; \ | |
134 | } while(0) | |
135 | ||
136 | struct task_struct; | |
137 | ||
138 | /* Free all resources held by a thread */ | |
139 | extern void release_thread(struct task_struct *); | |
140 | ||
141 | /* Create a kernel thread without removing it from tasklists */ | |
142 | extern int kernel_thread(int (*fn)(void *), void *arg, unsigned long flags); | |
143 | ||
144 | /* Prepare to copy thread state - unlazy all lazy status */ | |
145 | #define prepare_to_copy(tsk) do { } while(0) | |
146 | ||
147 | /* Return saved PC of a blocked thread */ | |
148 | #define thread_saved_pc(tsk) ((tsk)->thread.cpu_context.pc) | |
149 | ||
150 | struct pt_regs; | |
5f97f7f9 | 151 | extern unsigned long get_wchan(struct task_struct *p); |
623b0355 HS |
152 | extern void show_regs_log_lvl(struct pt_regs *regs, const char *log_lvl); |
153 | extern void show_stack_log_lvl(struct task_struct *tsk, unsigned long sp, | |
154 | struct pt_regs *regs, const char *log_lvl); | |
5f97f7f9 | 155 | |
2507bc13 HS |
156 | #define task_pt_regs(p) \ |
157 | ((struct pt_regs *)(THREAD_SIZE + task_stack_page(p)) - 1) | |
158 | ||
5f97f7f9 HS |
159 | #define KSTK_EIP(tsk) ((tsk)->thread.cpu_context.pc) |
160 | #define KSTK_ESP(tsk) ((tsk)->thread.cpu_context.ksp) | |
161 | ||
162 | #define ARCH_HAS_PREFETCH | |
163 | ||
164 | static inline void prefetch(const void *x) | |
165 | { | |
166 | const char *c = x; | |
167 | asm volatile("pref %0" : : "r"(c)); | |
168 | } | |
169 | #define PREFETCH_STRIDE L1_CACHE_BYTES | |
170 | ||
171 | #endif /* __ASSEMBLY__ */ | |
172 | ||
173 | #endif /* __ASM_AVR32_PROCESSOR_H */ |