2 * Copyright (C) 2006 Atmel Corporation
4 * SPDX-License-Identifier: GPL-2.0+
6 #ifndef __ASM_AVR32_PROCESSOR_H
7 #define __ASM_AVR32_PROCESSOR_H
11 #define current_text_addr() ({ void *pc; __asm__("mov %0,pc" : "=r"(pc)); pc; })
13 struct avr32_cpuinfo {
14 unsigned long loops_per_jiffy;
17 extern struct avr32_cpuinfo boot_cpu_data;
20 extern struct avr32_cpuinfo cpu_data[];
21 #define current_cpu_data cpu_data[smp_processor_id()]
23 #define cpu_data (&boot_cpu_data)
24 #define current_cpu_data boot_cpu_data
27 /* TODO: Make configurable (2GB will serve as a reasonable default) */
28 #define TASK_SIZE 0x80000000
30 /* This decides where the kernel will search for a free chunk of vm
33 #define TASK_UNMAPPED_BASE (TASK_SIZE / 3)
35 #define cpu_relax() barrier()
36 #define cpu_sync_pipeline() asm volatile("sub pc, -2" : : : "memory")
38 /* This struct contains the CPU context as stored by switch_to() */
39 struct thread_struct {
41 unsigned long ksp; /* Kernel stack pointer */
52 #define INIT_THREAD { \
53 .ksp = sizeof(init_stack) + (long)&init_stack, \
57 * Do necessary setup to start up a newly executed thread.
59 #define start_thread(regs, new_pc, new_sp) \
61 regs->sr = 0; /* User mode. */ \
62 regs->gr[REG_PC] = new_pc; \
63 regs->gr[REG_SP] = new_sp
67 /* Free all resources held by a thread */
68 extern void release_thread(struct task_struct *);
70 /* Create a kernel thread without removing it from tasklists */
71 extern int kernel_thread(int (*fn)(void *), void *arg, unsigned long flags);
73 /* Prepare to copy thread state - unlazy all lazy status */
74 #define prepare_to_copy(tsk) do { } while(0)
76 /* Return saved PC of a blocked thread */
77 #define thread_saved_pc(tsk) (tsk->thread.pc)
79 #endif /* __ASSEMBLY__ */
81 #endif /* __ASM_AVR32_PROCESSOR_H */