blob: 3e16ad9b0a99ab0615731f12bfffbf0195cf20d0 [file] [log] [blame]
Bryan Wu1394f032007-05-06 14:50:22 -07001/*
Robin Getz96f10502009-09-24 14:11:24 +00002 * Blackfin architecture-dependent process handling
Bryan Wu1394f032007-05-06 14:50:22 -07003 *
Robin Getz96f10502009-09-24 14:11:24 +00004 * Copyright 2004-2009 Analog Devices Inc.
Bryan Wu1394f032007-05-06 14:50:22 -07005 *
Robin Getz96f10502009-09-24 14:11:24 +00006 * Licensed under the GPL-2 or later
Bryan Wu1394f032007-05-06 14:50:22 -07007 */
8
9#include <linux/module.h>
Bryan Wu1394f032007-05-06 14:50:22 -070010#include <linux/unistd.h>
11#include <linux/user.h>
Mike Frysinger1f83b8f2007-07-12 22:58:21 +080012#include <linux/uaccess.h>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090013#include <linux/slab.h>
Vitja Makarov8b5f79f2008-02-29 12:24:23 +080014#include <linux/sched.h>
15#include <linux/tick.h>
Bryan Wud31c5ab2007-08-10 13:00:42 -070016#include <linux/fs.h>
17#include <linux/err.h>
Bryan Wu1394f032007-05-06 14:50:22 -070018
19#include <asm/blackfin.h>
Bernd Schmidt7adfb582007-06-21 11:34:16 +080020#include <asm/fixed_code.h>
Graf Yangdbc895f2009-01-07 23:14:39 +080021#include <asm/mem_map.h>
David Howells3bed8d62012-03-12 23:36:56 +000022#include <asm/irq.h>
Bryan Wu1394f032007-05-06 14:50:22 -070023
Bryan Wu1394f032007-05-06 14:50:22 -070024asmlinkage void ret_from_fork(void);
25
26/* Points to the SDRAM backup memory for the stack that is currently in
27 * L1 scratchpad memory.
28 */
29void *current_l1_stack_save;
30
31/* The number of tasks currently using a L1 stack area. The SRAM is
32 * allocated/deallocated whenever this changes from/to zero.
33 */
34int nr_l1stack_tasks;
35
36/* Start and length of the area in L1 scratchpad memory which we've allocated
37 * for process stacks.
38 */
39void *l1_stack_base;
40unsigned long l1_stack_len;
41
42/*
43 * Powermanagement idle function, if any..
44 */
45void (*pm_idle)(void) = NULL;
46EXPORT_SYMBOL(pm_idle);
47
48void (*pm_power_off)(void) = NULL;
49EXPORT_SYMBOL(pm_power_off);
50
51/*
Bryan Wu1394f032007-05-06 14:50:22 -070052 * The idle loop on BFIN
53 */
54#ifdef CONFIG_IDLE_L1
Vitja Makarov8b5f79f2008-02-29 12:24:23 +080055static void default_idle(void)__attribute__((l1_text));
Bryan Wu1394f032007-05-06 14:50:22 -070056void cpu_idle(void)__attribute__((l1_text));
57#endif
58
Vitja Makarov8b5f79f2008-02-29 12:24:23 +080059/*
60 * This is our default idle handler. We need to disable
61 * interrupts here to ensure we don't miss a wakeup call.
62 */
63static void default_idle(void)
Bryan Wu1394f032007-05-06 14:50:22 -070064{
Yi Li6a01f232009-01-07 23:14:39 +080065#ifdef CONFIG_IPIPE
66 ipipe_suspend_domain();
67#endif
David Howells3b139cd2010-10-07 14:08:52 +010068 hard_local_irq_disable();
Vitja Makarov8b5f79f2008-02-29 12:24:23 +080069 if (!need_resched())
70 idle_with_irq_disabled();
71
David Howells3b139cd2010-10-07 14:08:52 +010072 hard_local_irq_enable();
Bryan Wu1394f032007-05-06 14:50:22 -070073}
74
Bryan Wu1394f032007-05-06 14:50:22 -070075/*
Vitja Makarov8b5f79f2008-02-29 12:24:23 +080076 * The idle thread. We try to conserve power, while trying to keep
77 * overall latency low. The architecture specific idle is passed
78 * a value to indicate the level of "idleness" of the system.
Bryan Wu1394f032007-05-06 14:50:22 -070079 */
80void cpu_idle(void)
81{
82 /* endless idle loop with no priority at all */
83 while (1) {
Vitja Makarov8b5f79f2008-02-29 12:24:23 +080084 void (*idle)(void) = pm_idle;
85
86#ifdef CONFIG_HOTPLUG_CPU
87 if (cpu_is_offline(smp_processor_id()))
88 cpu_die();
89#endif
90 if (!idle)
91 idle = default_idle;
Frederic Weisbecker1268fbc2011-11-17 18:48:14 +010092 tick_nohz_idle_enter();
93 rcu_idle_enter();
Vitja Makarov8b5f79f2008-02-29 12:24:23 +080094 while (!need_resched())
95 idle();
Frederic Weisbecker1268fbc2011-11-17 18:48:14 +010096 rcu_idle_exit();
97 tick_nohz_idle_exit();
Bob Liub5affb02012-05-16 17:37:24 +080098 preempt_enable_no_resched();
99 schedule();
100 preempt_disable();
Bryan Wu1394f032007-05-06 14:50:22 -0700101 }
102}
103
Bryan Wu1394f032007-05-06 14:50:22 -0700104/*
Mike Frysingerd5ce5282009-06-13 11:32:34 -0400105 * Do necessary setup to start up a newly executed thread.
106 *
107 * pass the data segment into user programs if it exists,
108 * it can't hurt anything as far as I can tell
109 */
110void start_thread(struct pt_regs *regs, unsigned long new_ip, unsigned long new_sp)
111{
Mike Frysingerd5ce5282009-06-13 11:32:34 -0400112 regs->pc = new_ip;
113 if (current->mm)
114 regs->p5 = current->mm->start_data;
Graf Yangaa235312009-09-21 11:51:31 +0000115#ifndef CONFIG_SMP
Mike Frysingerd5ce5282009-06-13 11:32:34 -0400116 task_thread_info(current)->l1_task_info.stack_start =
117 (void *)current->mm->context.stack_start;
118 task_thread_info(current)->l1_task_info.lowest_sp = (void *)new_sp;
119 memcpy(L1_SCRATCH_TASK_INFO, &task_thread_info(current)->l1_task_info,
120 sizeof(*L1_SCRATCH_TASK_INFO));
121#endif
122 wrusp(new_sp);
123}
124EXPORT_SYMBOL_GPL(start_thread);
125
Bryan Wu1394f032007-05-06 14:50:22 -0700126void flush_thread(void)
127{
128}
129
Al Viro135c37b2012-11-13 23:47:37 -0500130asmlinkage int bfin_clone(unsigned long clone_flags, unsigned long newsp)
Bryan Wu1394f032007-05-06 14:50:22 -0700131{
Graf Yang8f658732008-11-18 17:48:22 +0800132#ifdef __ARCH_SYNC_CORE_DCACHE
Peter Zijlstra29baa742012-04-23 12:11:21 +0200133 if (current->nr_cpus_allowed == num_possible_cpus())
KOSAKI Motohiroe887eb62011-04-26 10:56:42 +0900134 set_cpus_allowed_ptr(current, cpumask_of(smp_processor_id()));
Graf Yang8f658732008-11-18 17:48:22 +0800135#endif
Al Viro135c37b2012-11-13 23:47:37 -0500136 if (newsp)
Bryan Wu1394f032007-05-06 14:50:22 -0700137 newsp -= 12;
Al Viroe80d6662012-10-22 23:10:08 -0400138 return do_fork(clone_flags, newsp, 0, NULL, NULL);
Bryan Wu1394f032007-05-06 14:50:22 -0700139}
140
141int
Alexey Dobriyan6f2c55b2009-04-02 16:56:59 -0700142copy_thread(unsigned long clone_flags,
Bryan Wu1394f032007-05-06 14:50:22 -0700143 unsigned long usp, unsigned long topstk,
Al Viroafa86fc2012-10-22 22:51:14 -0400144 struct task_struct *p)
Bryan Wu1394f032007-05-06 14:50:22 -0700145{
146 struct pt_regs *childregs;
Al Viroee1e17c2012-10-13 03:22:53 -0400147 unsigned long *v;
Bryan Wu1394f032007-05-06 14:50:22 -0700148
149 childregs = (struct pt_regs *) (task_stack_page(p) + THREAD_SIZE) - 1;
Al Viroee1e17c2012-10-13 03:22:53 -0400150 v = ((unsigned long *)childregs) - 2;
Al Viroafa86fc2012-10-22 22:51:14 -0400151 if (unlikely(p->flags & PF_KTHREAD)) {
Al Viroee1e17c2012-10-13 03:22:53 -0400152 memset(childregs, 0, sizeof(struct pt_regs));
153 v[0] = usp;
154 v[1] = topstk;
155 childregs->orig_p0 = -1;
156 childregs->ipend = 0x8000;
157 __asm__ __volatile__("%0 = syscfg;":"=da"(childregs->syscfg):);
158 p->thread.usp = 0;
159 } else {
Al Viroafa86fc2012-10-22 22:51:14 -0400160 *childregs = *current_pt_regs();
Al Viroee1e17c2012-10-13 03:22:53 -0400161 childregs->r0 = 0;
Al Viro135c37b2012-11-13 23:47:37 -0500162 p->thread.usp = usp ? : rdusp();
Al Viroee1e17c2012-10-13 03:22:53 -0400163 v[0] = v[1] = 0;
164 }
Bryan Wu1394f032007-05-06 14:50:22 -0700165
Al Viroee1e17c2012-10-13 03:22:53 -0400166 p->thread.ksp = (unsigned long)v;
Bryan Wu1394f032007-05-06 14:50:22 -0700167 p->thread.pc = (unsigned long)ret_from_fork;
168
169 return 0;
170}
171
Bryan Wu1394f032007-05-06 14:50:22 -0700172unsigned long get_wchan(struct task_struct *p)
173{
174 unsigned long fp, pc;
175 unsigned long stack_page;
176 int count = 0;
177 if (!p || p == current || p->state == TASK_RUNNING)
178 return 0;
179
180 stack_page = (unsigned long)p;
181 fp = p->thread.usp;
182 do {
183 if (fp < stack_page + sizeof(struct thread_info) ||
184 fp >= 8184 + stack_page)
185 return 0;
186 pc = ((unsigned long *)fp)[1];
187 if (!in_sched_functions(pc))
188 return pc;
189 fp = *(unsigned long *)fp;
190 }
191 while (count++ < 16);
192 return 0;
193}
194
Bernd Schmidt7adfb582007-06-21 11:34:16 +0800195void finish_atomic_sections (struct pt_regs *regs)
196{
Bernd Schmidt19d6d7d2008-05-07 11:41:26 +0800197 int __user *up0 = (int __user *)regs->p0;
Mike Frysinger0ddeeca2008-03-07 02:37:41 +0800198
Bernd Schmidt7adfb582007-06-21 11:34:16 +0800199 switch (regs->pc) {
Mike Frysinger2f5a0862009-11-19 19:15:26 +0000200 default:
201 /* not in middle of an atomic step, so resume like normal */
202 return;
203
Bernd Schmidt7adfb582007-06-21 11:34:16 +0800204 case ATOMIC_XCHG32 + 2:
Mike Frysinger0ddeeca2008-03-07 02:37:41 +0800205 put_user(regs->r1, up0);
Bernd Schmidt7adfb582007-06-21 11:34:16 +0800206 break;
207
208 case ATOMIC_CAS32 + 2:
209 case ATOMIC_CAS32 + 4:
210 if (regs->r0 == regs->r1)
Mike Frysinger92649492009-08-17 19:05:07 +0000211 case ATOMIC_CAS32 + 6:
Mike Frysinger0ddeeca2008-03-07 02:37:41 +0800212 put_user(regs->r2, up0);
Bernd Schmidt7adfb582007-06-21 11:34:16 +0800213 break;
Bernd Schmidt7adfb582007-06-21 11:34:16 +0800214
215 case ATOMIC_ADD32 + 2:
216 regs->r0 = regs->r1 + regs->r0;
217 /* fall through */
218 case ATOMIC_ADD32 + 4:
Mike Frysinger0ddeeca2008-03-07 02:37:41 +0800219 put_user(regs->r0, up0);
Bernd Schmidt7adfb582007-06-21 11:34:16 +0800220 break;
221
222 case ATOMIC_SUB32 + 2:
223 regs->r0 = regs->r1 - regs->r0;
224 /* fall through */
225 case ATOMIC_SUB32 + 4:
Mike Frysinger0ddeeca2008-03-07 02:37:41 +0800226 put_user(regs->r0, up0);
Bernd Schmidt7adfb582007-06-21 11:34:16 +0800227 break;
228
229 case ATOMIC_IOR32 + 2:
230 regs->r0 = regs->r1 | regs->r0;
231 /* fall through */
232 case ATOMIC_IOR32 + 4:
Mike Frysinger0ddeeca2008-03-07 02:37:41 +0800233 put_user(regs->r0, up0);
Bernd Schmidt7adfb582007-06-21 11:34:16 +0800234 break;
235
236 case ATOMIC_AND32 + 2:
237 regs->r0 = regs->r1 & regs->r0;
238 /* fall through */
239 case ATOMIC_AND32 + 4:
Mike Frysinger0ddeeca2008-03-07 02:37:41 +0800240 put_user(regs->r0, up0);
Bernd Schmidt7adfb582007-06-21 11:34:16 +0800241 break;
242
243 case ATOMIC_XOR32 + 2:
244 regs->r0 = regs->r1 ^ regs->r0;
245 /* fall through */
246 case ATOMIC_XOR32 + 4:
Mike Frysinger0ddeeca2008-03-07 02:37:41 +0800247 put_user(regs->r0, up0);
Bernd Schmidt7adfb582007-06-21 11:34:16 +0800248 break;
249 }
Mike Frysinger2f5a0862009-11-19 19:15:26 +0000250
251 /*
252 * We've finished the atomic section, and the only thing left for
253 * userspace is to do a RTS, so we might as well handle that too
254 * since we need to update the PC anyways.
255 */
256 regs->pc = regs->rets;
Bernd Schmidt7adfb582007-06-21 11:34:16 +0800257}
258
Mike Frysingere56e03b2009-06-07 16:31:52 -0400259static inline
260int in_mem(unsigned long addr, unsigned long size,
261 unsigned long start, unsigned long end)
262{
263 return addr >= start && addr + size <= end;
264}
265static inline
266int in_mem_const_off(unsigned long addr, unsigned long size, unsigned long off,
267 unsigned long const_addr, unsigned long const_size)
268{
269 return const_size &&
270 in_mem(addr, size, const_addr + off, const_addr + const_size);
271}
272static inline
273int in_mem_const(unsigned long addr, unsigned long size,
274 unsigned long const_addr, unsigned long const_size)
275{
Mike Frysingerfb4b5d32009-06-29 14:20:10 -0400276 return in_mem_const_off(addr, size, 0, const_addr, const_size);
Mike Frysingere56e03b2009-06-07 16:31:52 -0400277}
Bob Liub5affb02012-05-16 17:37:24 +0800278#ifdef CONFIG_BF60x
279#define ASYNC_ENABLED(bnum, bctlnum) 1
280#else
Bernd Schmidt13048f82009-09-23 16:47:16 +0000281#define ASYNC_ENABLED(bnum, bctlnum) \
Mike Frysingere56e03b2009-06-07 16:31:52 -0400282({ \
Bernd Schmidt13048f82009-09-23 16:47:16 +0000283 (bfin_read_EBIU_AMGCTL() & 0xe) < ((bnum + 1) << 1) ? 0 : \
284 bfin_read_EBIU_AMBCTL##bctlnum() & B##bnum##RDYEN ? 0 : \
285 1; \
Mike Frysingere56e03b2009-06-07 16:31:52 -0400286})
Bob Liub5affb02012-05-16 17:37:24 +0800287#endif
Bernd Schmidt13048f82009-09-23 16:47:16 +0000288/*
289 * We can't read EBIU banks that aren't enabled or we end up hanging
290 * on the access to the async space. Make sure we validate accesses
291 * that cross async banks too.
292 * 0 - found, but unusable
293 * 1 - found & usable
294 * 2 - not found
295 */
296static
297int in_async(unsigned long addr, unsigned long size)
298{
299 if (addr >= ASYNC_BANK0_BASE && addr < ASYNC_BANK0_BASE + ASYNC_BANK0_SIZE) {
300 if (!ASYNC_ENABLED(0, 0))
301 return 0;
302 if (addr + size <= ASYNC_BANK0_BASE + ASYNC_BANK0_SIZE)
303 return 1;
304 size -= ASYNC_BANK0_BASE + ASYNC_BANK0_SIZE - addr;
305 addr = ASYNC_BANK0_BASE + ASYNC_BANK0_SIZE;
306 }
307 if (addr >= ASYNC_BANK1_BASE && addr < ASYNC_BANK1_BASE + ASYNC_BANK1_SIZE) {
308 if (!ASYNC_ENABLED(1, 0))
309 return 0;
310 if (addr + size <= ASYNC_BANK1_BASE + ASYNC_BANK1_SIZE)
311 return 1;
312 size -= ASYNC_BANK1_BASE + ASYNC_BANK1_SIZE - addr;
313 addr = ASYNC_BANK1_BASE + ASYNC_BANK1_SIZE;
314 }
315 if (addr >= ASYNC_BANK2_BASE && addr < ASYNC_BANK2_BASE + ASYNC_BANK2_SIZE) {
316 if (!ASYNC_ENABLED(2, 1))
317 return 0;
318 if (addr + size <= ASYNC_BANK2_BASE + ASYNC_BANK2_SIZE)
319 return 1;
320 size -= ASYNC_BANK2_BASE + ASYNC_BANK2_SIZE - addr;
321 addr = ASYNC_BANK2_BASE + ASYNC_BANK2_SIZE;
322 }
323 if (addr >= ASYNC_BANK3_BASE && addr < ASYNC_BANK3_BASE + ASYNC_BANK3_SIZE) {
324 if (ASYNC_ENABLED(3, 1))
325 return 0;
326 if (addr + size <= ASYNC_BANK3_BASE + ASYNC_BANK3_SIZE)
327 return 1;
328 return 0;
329 }
330
331 /* not within async bounds */
332 return 2;
333}
Mike Frysingere56e03b2009-06-07 16:31:52 -0400334
335int bfin_mem_access_type(unsigned long addr, unsigned long size)
336{
337 int cpu = raw_smp_processor_id();
338
339 /* Check that things do not wrap around */
340 if (addr > ULONG_MAX - size)
341 return -EFAULT;
342
343 if (in_mem(addr, size, FIXED_CODE_START, physical_mem_end))
344 return BFIN_MEM_ACCESS_CORE;
345
346 if (in_mem_const(addr, size, L1_CODE_START, L1_CODE_LENGTH))
347 return cpu == 0 ? BFIN_MEM_ACCESS_ITEST : BFIN_MEM_ACCESS_IDMA;
348 if (in_mem_const(addr, size, L1_SCRATCH_START, L1_SCRATCH_LENGTH))
349 return cpu == 0 ? BFIN_MEM_ACCESS_CORE_ONLY : -EFAULT;
350 if (in_mem_const(addr, size, L1_DATA_A_START, L1_DATA_A_LENGTH))
351 return cpu == 0 ? BFIN_MEM_ACCESS_CORE : BFIN_MEM_ACCESS_IDMA;
352 if (in_mem_const(addr, size, L1_DATA_B_START, L1_DATA_B_LENGTH))
353 return cpu == 0 ? BFIN_MEM_ACCESS_CORE : BFIN_MEM_ACCESS_IDMA;
354#ifdef COREB_L1_CODE_START
Mike Frysingerfb4b5d32009-06-29 14:20:10 -0400355 if (in_mem_const(addr, size, COREB_L1_CODE_START, COREB_L1_CODE_LENGTH))
Mike Frysingere56e03b2009-06-07 16:31:52 -0400356 return cpu == 1 ? BFIN_MEM_ACCESS_ITEST : BFIN_MEM_ACCESS_IDMA;
357 if (in_mem_const(addr, size, COREB_L1_SCRATCH_START, L1_SCRATCH_LENGTH))
358 return cpu == 1 ? BFIN_MEM_ACCESS_CORE_ONLY : -EFAULT;
Mike Frysingerfb4b5d32009-06-29 14:20:10 -0400359 if (in_mem_const(addr, size, COREB_L1_DATA_A_START, COREB_L1_DATA_A_LENGTH))
Mike Frysingere56e03b2009-06-07 16:31:52 -0400360 return cpu == 1 ? BFIN_MEM_ACCESS_CORE : BFIN_MEM_ACCESS_IDMA;
Mike Frysingerfb4b5d32009-06-29 14:20:10 -0400361 if (in_mem_const(addr, size, COREB_L1_DATA_B_START, COREB_L1_DATA_B_LENGTH))
Mike Frysingere56e03b2009-06-07 16:31:52 -0400362 return cpu == 1 ? BFIN_MEM_ACCESS_CORE : BFIN_MEM_ACCESS_IDMA;
363#endif
364 if (in_mem_const(addr, size, L2_START, L2_LENGTH))
365 return BFIN_MEM_ACCESS_CORE;
366
367 if (addr >= SYSMMR_BASE)
368 return BFIN_MEM_ACCESS_CORE_ONLY;
369
Bernd Schmidt13048f82009-09-23 16:47:16 +0000370 switch (in_async(addr, size)) {
371 case 0: return -EFAULT;
372 case 1: return BFIN_MEM_ACCESS_CORE;
373 case 2: /* fall through */;
374 }
Mike Frysingere56e03b2009-06-07 16:31:52 -0400375
376 if (in_mem_const(addr, size, BOOT_ROM_START, BOOT_ROM_LENGTH))
377 return BFIN_MEM_ACCESS_CORE;
378 if (in_mem_const(addr, size, L1_ROM_START, L1_ROM_LENGTH))
379 return BFIN_MEM_ACCESS_DMA;
380
381 return -EFAULT;
382}
383
Bryan Wu1394f032007-05-06 14:50:22 -0700384#if defined(CONFIG_ACCESS_CHECK)
Mike Frysingera43b7392009-06-04 19:24:31 +0000385#ifdef CONFIG_ACCESS_OK_L1
386__attribute__((l1_text))
387#endif
Robin Getzb03b08b2007-12-23 22:57:01 +0800388/* Return 1 if access to memory range is OK, 0 otherwise */
Bryan Wu1394f032007-05-06 14:50:22 -0700389int _access_ok(unsigned long addr, unsigned long size)
390{
Bernd Schmidt13048f82009-09-23 16:47:16 +0000391 int aret;
392
Bernd Schmidtbc41bb12007-10-10 17:54:19 +0800393 if (size == 0)
394 return 1;
Mike Frysingere56e03b2009-06-07 16:31:52 -0400395 /* Check that things do not wrap around */
396 if (addr > ULONG_MAX - size)
Bryan Wu1394f032007-05-06 14:50:22 -0700397 return 0;
Mike Frysinger1f83b8f2007-07-12 22:58:21 +0800398 if (segment_eq(get_fs(), KERNEL_DS))
Bryan Wu1394f032007-05-06 14:50:22 -0700399 return 1;
400#ifdef CONFIG_MTD_UCLINUX
Mike Frysingere56e03b2009-06-07 16:31:52 -0400401 if (1)
402#else
403 if (0)
404#endif
405 {
406 if (in_mem(addr, size, memory_start, memory_end))
407 return 1;
408 if (in_mem(addr, size, memory_mtd_end, physical_mem_end))
409 return 1;
410# ifndef CONFIG_ROMFS_ON_MTD
411 if (0)
412# endif
413 /* For XIP, allow user space to use pointers within the ROMFS. */
414 if (in_mem(addr, size, memory_mtd_start, memory_mtd_end))
415 return 1;
416 } else {
417 if (in_mem(addr, size, memory_start, physical_mem_end))
418 return 1;
419 }
420
421 if (in_mem(addr, size, (unsigned long)__init_begin, (unsigned long)__init_end))
Bryan Wu1394f032007-05-06 14:50:22 -0700422 return 1;
Bernd Schmidtd5adb022008-04-24 03:06:15 +0800423
Mike Frysingere56e03b2009-06-07 16:31:52 -0400424 if (in_mem_const(addr, size, L1_CODE_START, L1_CODE_LENGTH))
425 return 1;
426 if (in_mem_const_off(addr, size, _etext_l1 - _stext_l1, L1_CODE_START, L1_CODE_LENGTH))
427 return 1;
428 if (in_mem_const_off(addr, size, _ebss_l1 - _sdata_l1, L1_DATA_A_START, L1_DATA_A_LENGTH))
429 return 1;
430 if (in_mem_const_off(addr, size, _ebss_b_l1 - _sdata_b_l1, L1_DATA_B_START, L1_DATA_B_LENGTH))
431 return 1;
432#ifdef COREB_L1_CODE_START
Mike Frysingerfb4b5d32009-06-29 14:20:10 -0400433 if (in_mem_const(addr, size, COREB_L1_CODE_START, COREB_L1_CODE_LENGTH))
Mike Frysingere56e03b2009-06-07 16:31:52 -0400434 return 1;
435 if (in_mem_const(addr, size, COREB_L1_SCRATCH_START, L1_SCRATCH_LENGTH))
436 return 1;
Mike Frysingerfb4b5d32009-06-29 14:20:10 -0400437 if (in_mem_const(addr, size, COREB_L1_DATA_A_START, COREB_L1_DATA_A_LENGTH))
Mike Frysingere56e03b2009-06-07 16:31:52 -0400438 return 1;
Mike Frysingerfb4b5d32009-06-29 14:20:10 -0400439 if (in_mem_const(addr, size, COREB_L1_DATA_B_START, COREB_L1_DATA_B_LENGTH))
Bernd Schmidtd5adb022008-04-24 03:06:15 +0800440 return 1;
441#endif
Bernd Schmidt13048f82009-09-23 16:47:16 +0000442
Barry Song41c3e332010-06-29 08:43:38 +0000443#ifndef CONFIG_EXCEPTION_L1_SCRATCH
444 if (in_mem_const(addr, size, (unsigned long)l1_stack_base, l1_stack_len))
445 return 1;
446#endif
447
Bernd Schmidt13048f82009-09-23 16:47:16 +0000448 aret = in_async(addr, size);
449 if (aret < 2)
450 return aret;
451
Mike Frysingere56e03b2009-06-07 16:31:52 -0400452 if (in_mem_const_off(addr, size, _ebss_l2 - _stext_l2, L2_START, L2_LENGTH))
Bryan Wu1394f032007-05-06 14:50:22 -0700453 return 1;
Mike Frysingere56e03b2009-06-07 16:31:52 -0400454
455 if (in_mem_const(addr, size, BOOT_ROM_START, BOOT_ROM_LENGTH))
Bryan Wu1394f032007-05-06 14:50:22 -0700456 return 1;
Mike Frysingere56e03b2009-06-07 16:31:52 -0400457 if (in_mem_const(addr, size, L1_ROM_START, L1_ROM_LENGTH))
Bryan Wu1394f032007-05-06 14:50:22 -0700458 return 1;
Mike Frysingere56e03b2009-06-07 16:31:52 -0400459
Bryan Wu1394f032007-05-06 14:50:22 -0700460 return 0;
461}
462EXPORT_SYMBOL(_access_ok);
463#endif /* CONFIG_ACCESS_CHECK */