1/* 2 * include/asm-m68k/processor.h 3 * 4 * Copyright (C) 1995 Hamish Macdonald 5 */ 6 7#ifndef __ASM_M68K_PROCESSOR_H 8#define __ASM_M68K_PROCESSOR_H 9 10/* 11 * Default implementation of macro that returns current 12 * instruction pointer ("program counter"). 13 */ 14#define current_text_addr() ({ __label__ _l; _l: &&_l;}) 15 16#include <linux/thread_info.h> 17#include <asm/segment.h> 18#include <asm/fpu.h> 19#include <asm/ptrace.h> 20 21static inline unsigned long rdusp(void) 22{ 23#ifdef CONFIG_COLDFIRE 24 extern unsigned int sw_usp; 25 return sw_usp; 26#else 27 unsigned long usp; 28 __asm__ __volatile__("move %/usp,%0" : "=a" (usp)); 29 return usp; 30#endif 31} 32 33static inline void wrusp(unsigned long usp) 34{ 35#ifdef CONFIG_COLDFIRE 36 extern unsigned int sw_usp; 37 sw_usp = usp; 38#else 39 __asm__ __volatile__("move %0,%/usp" : : "a" (usp)); 40#endif 41} 42 43/* 44 * User space process size: 3.75GB. This is hardcoded into a few places, 45 * so don't change it unless you know what you are doing. 46 */ 47#ifdef CONFIG_MMU 48#ifndef CONFIG_SUN3 49#define TASK_SIZE (0xF0000000UL) 50#else 51#define TASK_SIZE (0x0E000000UL) 52#endif 53#else 54#define TASK_SIZE (0xFFFFFFFFUL) 55#endif 56 57#ifdef __KERNEL__ 58#define STACK_TOP TASK_SIZE 59#define STACK_TOP_MAX STACK_TOP 60#endif 61 62/* This decides where the kernel will search for a free chunk of vm 63 * space during mmap's. 64 */ 65#ifdef CONFIG_MMU 66#ifndef CONFIG_SUN3 67#define TASK_UNMAPPED_BASE 0xC0000000UL 68#else 69#define TASK_UNMAPPED_BASE 0x0A000000UL 70#endif 71#define TASK_UNMAPPED_ALIGN(addr, off) PAGE_ALIGN(addr) 72#else 73#define TASK_UNMAPPED_BASE 0 74#endif 75 76struct thread_struct { 77 unsigned long ksp; /* kernel stack pointer */ 78 unsigned long usp; /* user stack pointer */ 79 unsigned short sr; /* saved status register */ 80 unsigned short fs; /* saved fs (sfc, dfc) */ 81 unsigned long crp[2]; /* cpu root pointer */ 82 unsigned long esp0; /* points to SR of stack frame */ 83 unsigned long faddr; /* info about last fault */ 84 int signo, code; 85 unsigned long fp[8*3]; 86 unsigned long fpcntl[3]; /* fp control regs */ 87 unsigned char fpstate[FPSTATESIZE]; /* floating point state */ 88 struct thread_info info; 89}; 90 91#define INIT_THREAD { \ 92 .ksp = sizeof(init_stack) + (unsigned long) init_stack, \ 93 .sr = PS_S, \ 94 .fs = __KERNEL_DS, \ 95 .info = INIT_THREAD_INFO(init_task), \ 96} 97 98#ifdef CONFIG_MMU 99/* 100 * Do necessary setup to start up a newly executed thread. 101 */ 102static inline void start_thread(struct pt_regs * regs, unsigned long pc, 103 unsigned long usp) 104{ 105 /* reads from user space */ 106 set_fs(USER_DS); 107 108 regs->pc = pc; 109 regs->sr &= ~0x2000; 110 wrusp(usp); 111} 112 113#else 114 115/* 116 * Coldfire stacks need to be re-aligned on trap exit, conventional 117 * 68k can handle this case cleanly. 118 */ 119#ifdef CONFIG_COLDFIRE 120#define reformat(_regs) do { (_regs)->format = 0x4; } while(0) 121#else 122#define reformat(_regs) do { } while (0) 123#endif 124 125#define start_thread(_regs, _pc, _usp) \ 126do { \ 127 set_fs(USER_DS); /* reads from user space */ \ 128 (_regs)->pc = (_pc); \ 129 ((struct switch_stack *)(_regs))[-1].a6 = 0; \ 130 reformat(_regs); \ 131 if (current->mm) \ 132 (_regs)->d5 = current->mm->start_data; \ 133 (_regs)->sr &= ~0x2000; \ 134 wrusp(_usp); \ 135} while(0) 136 137#endif 138 139/* Forward declaration, a strange C thing */ 140struct task_struct; 141 142/* Free all resources held by a thread. */ 143static inline void release_thread(struct task_struct *dead_task) 144{ 145} 146 147/* Prepare to copy thread state - unlazy all lazy status */ 148#define prepare_to_copy(tsk) do { } while (0) 149 150extern int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags); 151 152/* 153 * Free current thread data structures etc.. 154 */ 155static inline void exit_thread(void) 156{ 157} 158 159extern unsigned long thread_saved_pc(struct task_struct *tsk); 160 161unsigned long get_wchan(struct task_struct *p); 162 163#define KSTK_EIP(tsk) \ 164 ({ \ 165 unsigned long eip = 0; \ 166 if ((tsk)->thread.esp0 > PAGE_SIZE && \ 167 (virt_addr_valid((tsk)->thread.esp0))) \ 168 eip = ((struct pt_regs *) (tsk)->thread.esp0)->pc; \ 169 eip; }) 170#define KSTK_ESP(tsk) ((tsk) == current ? rdusp() : (tsk)->thread.usp) 171 172#define task_pt_regs(tsk) ((struct pt_regs *) ((tsk)->thread.esp0)) 173 174#define cpu_relax() barrier() 175 176#endif 177