blob: 74d868cdc8481d1e7483fa615b68c425c9e5193d [file] [log] [blame]
Wolfgang Denk83c15852006-10-24 14:21:16 +02001/*
2 * Copyright (C) 2006 Atmel Corporation
3 *
Wolfgang Denkd79de1d2013-07-08 09:37:19 +02004 * SPDX-License-Identifier: GPL-2.0+
Wolfgang Denk83c15852006-10-24 14:21:16 +02005 */
6#ifndef __ASM_AVR32_PROCESSOR_H
7#define __ASM_AVR32_PROCESSOR_H
8
9#ifndef __ASSEMBLY__
10
11#define current_text_addr() ({ void *pc; __asm__("mov %0,pc" : "=r"(pc)); pc; })
12
13struct avr32_cpuinfo {
14 unsigned long loops_per_jiffy;
15};
16
17extern struct avr32_cpuinfo boot_cpu_data;
18
19#ifdef CONFIG_SMP
20extern struct avr32_cpuinfo cpu_data[];
21#define current_cpu_data cpu_data[smp_processor_id()]
22#else
23#define cpu_data (&boot_cpu_data)
24#define current_cpu_data boot_cpu_data
25#endif
26
27/* TODO: Make configurable (2GB will serve as a reasonable default) */
28#define TASK_SIZE 0x80000000
29
30/* This decides where the kernel will search for a free chunk of vm
31 * space during mmap's
32 */
33#define TASK_UNMAPPED_BASE (TASK_SIZE / 3)
34
35#define cpu_relax() barrier()
36#define cpu_sync_pipeline() asm volatile("sub pc, -2" : : : "memory")
37
38/* This struct contains the CPU context as stored by switch_to() */
39struct thread_struct {
40 unsigned long pc;
41 unsigned long ksp; /* Kernel stack pointer */
42 unsigned long r7;
43 unsigned long r6;
44 unsigned long r5;
45 unsigned long r4;
46 unsigned long r3;
47 unsigned long r2;
48 unsigned long r1;
49 unsigned long r0;
50};
51
52#define INIT_THREAD { \
53 .ksp = sizeof(init_stack) + (long)&init_stack, \
54}
55
56/*
57 * Do necessary setup to start up a newly executed thread.
58 */
59#define start_thread(regs, new_pc, new_sp) \
60 set_fs(USER_DS); \
61 regs->sr = 0; /* User mode. */ \
62 regs->gr[REG_PC] = new_pc; \
63 regs->gr[REG_SP] = new_sp
64
65struct task_struct;
66
67/* Free all resources held by a thread */
68extern void release_thread(struct task_struct *);
69
70/* Create a kernel thread without removing it from tasklists */
71extern int kernel_thread(int (*fn)(void *), void *arg, unsigned long flags);
72
73/* Prepare to copy thread state - unlazy all lazy status */
74#define prepare_to_copy(tsk) do { } while(0)
75
76/* Return saved PC of a blocked thread */
77#define thread_saved_pc(tsk) (tsk->thread.pc)
78
79#endif /* __ASSEMBLY__ */
80
81#endif /* __ASM_AVR32_PROCESSOR_H */