1 /* SPDX-License-Identifier: GPL-2.0 */
3 * include/asm-m68k/processor.h
5 * Copyright (C) 1995 Hamish Macdonald
8 #ifndef __ASM_M68K_PROCESSOR_H
9 #define __ASM_M68K_PROCESSOR_H
11 #include <linux/thread_info.h>
13 #include <asm/ptrace.h>
15 static inline unsigned long rdusp(void)
17 #ifdef CONFIG_COLDFIRE_SW_A7
18 extern unsigned int sw_usp;
21 register unsigned long usp __asm__("a0");
23 __asm__ __volatile__(".word 0x4e68" : "=a" (usp));
28 static inline void wrusp(unsigned long usp)
30 #ifdef CONFIG_COLDFIRE_SW_A7
31 extern unsigned int sw_usp;
34 register unsigned long a0 __asm__("a0") = usp;
36 __asm__ __volatile__(".word 0x4e60" : : "a" (a0) );
41 * User space process size: 3.75GB. This is hardcoded into a few places,
42 * so don't change it unless you know what you are doing.
45 #if defined(CONFIG_COLDFIRE)
46 #define TASK_SIZE (0xC0000000UL)
47 #elif defined(CONFIG_SUN3)
48 #define TASK_SIZE (0x0E000000UL)
50 #define TASK_SIZE (0xF0000000UL)
53 #define TASK_SIZE (0xFFFFFFFFUL)
57 #define STACK_TOP TASK_SIZE
58 #define STACK_TOP_MAX STACK_TOP
61 /* This decides where the kernel will search for a free chunk of vm
62 * space during mmap's.
65 #if defined(CONFIG_COLDFIRE)
66 #define TASK_UNMAPPED_BASE 0x60000000UL
67 #elif defined(CONFIG_SUN3)
68 #define TASK_UNMAPPED_BASE 0x0A000000UL
70 #define TASK_UNMAPPED_BASE 0xC0000000UL
72 #define TASK_UNMAPPED_ALIGN(addr, off) PAGE_ALIGN(addr)
74 #define TASK_UNMAPPED_BASE 0
77 /* Address spaces (or Function Codes in Motorola lingo) */
79 #define USER_PROGRAM 2
81 #define SUPER_PROGRAM 6
84 #ifdef CONFIG_CPU_HAS_ADDRESS_SPACES
86 * Set the SFC/DFC registers for special MM operations. For most normal
87 * operation these remain set to USER_DATA for the uaccess routines.
89 static inline void set_fc(unsigned long val)
91 WARN_ON_ONCE(in_interrupt());
93 __asm__ __volatile__ ("movec %0,%/sfc\n\t"
95 : /* no outputs */ : "r" (val) : "memory");
98 static inline void set_fc(unsigned long val)
101 #endif /* CONFIG_CPU_HAS_ADDRESS_SPACES */
103 struct thread_struct {
104 unsigned long ksp; /* kernel stack pointer */
105 unsigned long usp; /* user stack pointer */
106 unsigned short sr; /* saved status register */
107 unsigned short fc; /* saved fc (sfc, dfc) */
108 unsigned long crp[2]; /* cpu root pointer */
109 unsigned long esp0; /* points to SR of stack frame */
110 unsigned long faddr; /* info about last fault */
112 unsigned long fp[8*3];
113 unsigned long fpcntl[3]; /* fp control regs */
114 unsigned char fpstate[FPSTATESIZE]; /* floating point state */
117 #define INIT_THREAD { \
118 .ksp = sizeof(init_stack) + (unsigned long) init_stack, \
124 * ColdFire stack format sbould be 0x4 for an aligned usp (will always be
125 * true on thread creation). We need to set this explicitly.
127 #ifdef CONFIG_COLDFIRE
128 #define setframeformat(_regs) do { (_regs)->format = 0x4; } while(0)
130 #define setframeformat(_regs) do { } while (0)
134 * Do necessary setup to start up a newly executed thread.
136 static inline void start_thread(struct pt_regs * regs, unsigned long pc,
141 setframeformat(regs);
145 /* Forward declaration, a strange C thing */
148 unsigned long __get_wchan(struct task_struct *p);
149 void show_registers(struct pt_regs *regs);
151 #define KSTK_EIP(tsk) \
153 unsigned long eip = 0; \
154 if ((tsk)->thread.esp0 > PAGE_SIZE && \
155 (virt_addr_valid((tsk)->thread.esp0))) \
156 eip = ((struct pt_regs *) (tsk)->thread.esp0)->pc; \
158 #define KSTK_ESP(tsk) ((tsk) == current ? rdusp() : (tsk)->thread.usp)
160 #define task_pt_regs(tsk) ((struct pt_regs *) ((tsk)->thread.esp0))
162 #define cpu_relax() barrier()