1af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt/* 2af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt * include/asm-sh/processor.h 3af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt * 4af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt * Copyright (C) 1999, 2000 Niibe Yutaka 5af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt * Copyright (C) 2002, 2003 Paul Mundt 6af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt */ 7af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt 8af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt#ifndef __ASM_SH_PROCESSOR_32_H 9af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt#define __ASM_SH_PROCESSOR_32_H 10af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt#ifdef __KERNEL__ 11af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt 12af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt#include <linux/compiler.h> 13fa43972fab24a3c050e880a7831f9378c6cebc0bPaul Mundt#include <linux/linkage.h> 14af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt#include <asm/page.h> 15af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt#include <asm/types.h> 164352fc1b12fae4c753a063a2f162ddf9277af774Paul Mundt#include <asm/hw_breakpoint.h> 17af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt 18af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt/* 19af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt * Default implementation of macro that returns current 20af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt * instruction pointer ("program counter"). 21af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt */ 22103340cc36384c1afee4453b65a784d8b20d9d8dPaul Mundt#define current_text_addr() ({ void *pc; __asm__("mova 1f, %0\n.align 2\n1:":"=z" (pc)); pc; }) 23af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt 24af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt/* Core Processor Version Register */ 25af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt#define CCN_PVR 0xff000030 26af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt#define CCN_CVR 0xff000040 27af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt#define CCN_PRR 0xff000044 28af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt 29af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt/* 30af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt * User space process size: 2GB. 31af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt * 32af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt * Since SH7709 and SH7750 have "area 7", we can't use 0x7c000000--0x7fffffff 33af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt */ 34af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt#define TASK_SIZE 0x7c000000UL 35af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt 36922a70d327bd4b11342c2afd08e20d35f52064c3David Howells#define STACK_TOP TASK_SIZE 37922a70d327bd4b11342c2afd08e20d35f52064c3David Howells#define STACK_TOP_MAX STACK_TOP 38922a70d327bd4b11342c2afd08e20d35f52064c3David Howells 39af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt/* This decides where the kernel will search for a free chunk of vm 40af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt * space during mmap's. 41af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt */ 42af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt#define TASK_UNMAPPED_BASE (TASK_SIZE / 3) 43af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt 44af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt/* 45af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt * Bit of SR register 46af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt * 47af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt * FD-bit: 48af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt * When it's set, it means the processor doesn't have right to use FPU, 49af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt * and it results exception when the floating operation is executed. 50af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt * 51af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt * IMASK-bit: 52af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt * Interrupt level mask 53af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt */ 54af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt#define SR_DSP 0x00001000 55af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt#define SR_IMASK 0x000000f0 569bbafce2eec190ef7e44b0eb1095ba17ce6ad3afPaul Mundt#define SR_FD 0x00008000 57d3ea9fa0a563620fe9f416f94bb8927c64390917Stuart Menefy#define SR_MD 0x40000000 58af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt 59af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt/* 6001ab10393c510342ec4ce85df11ccfa3df06bbb2Michael Trimarchi * DSP structure and data 6101ab10393c510342ec4ce85df11ccfa3df06bbb2Michael Trimarchi */ 6201ab10393c510342ec4ce85df11ccfa3df06bbb2Michael Trimarchistruct sh_dsp_struct { 6301ab10393c510342ec4ce85df11ccfa3df06bbb2Michael Trimarchi unsigned long dsp_regs[14]; 6401ab10393c510342ec4ce85df11ccfa3df06bbb2Michael Trimarchi long status; 6501ab10393c510342ec4ce85df11ccfa3df06bbb2Michael Trimarchi}; 6601ab10393c510342ec4ce85df11ccfa3df06bbb2Michael Trimarchi 6701ab10393c510342ec4ce85df11ccfa3df06bbb2Michael Trimarchi/* 68af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt * FPU structure and data 69af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt */ 70af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt 71af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundtstruct sh_fpu_hard_struct { 72af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt unsigned long fp_regs[16]; 73af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt unsigned long xfp_regs[16]; 74af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt unsigned long fpscr; 75af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt unsigned long fpul; 76af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt 77af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt long status; /* software status information */ 78af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt}; 79af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt 80af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt/* Dummy fpu emulator */ 81af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundtstruct sh_fpu_soft_struct { 82af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt unsigned long fp_regs[16]; 83af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt unsigned long xfp_regs[16]; 84af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt unsigned long fpscr; 85af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt unsigned long fpul; 86af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt 87af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt unsigned char lookahead; 88af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt unsigned long entry_pc; 89af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt}; 90af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt 910ea820cf9bf58f735ed40ec67947159c4f170012Paul Mundtunion thread_xstate { 920ea820cf9bf58f735ed40ec67947159c4f170012Paul Mundt struct sh_fpu_hard_struct hardfpu; 930ea820cf9bf58f735ed40ec67947159c4f170012Paul Mundt struct sh_fpu_soft_struct softfpu; 94af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt}; 95af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt 96af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundtstruct thread_struct { 97af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt /* Saved registers when thread is descheduled */ 98af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt unsigned long sp; 99af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt unsigned long pc; 100af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt 10194ea5e449ae834af058ef005d16a8ad44fcf13d6Paul Mundt /* Various thread flags, see SH_THREAD_xxx */ 10294ea5e449ae834af058ef005d16a8ad44fcf13d6Paul Mundt unsigned long flags; 10394ea5e449ae834af058ef005d16a8ad44fcf13d6Paul Mundt 10409a072947791088b88ae15111cf68fc5aaaf758dPaul Mundt /* Save middle states of ptrace breakpoints */ 10594ea5e449ae834af058ef005d16a8ad44fcf13d6Paul Mundt struct perf_event *ptrace_bps[HBP_NUM]; 10601ab10393c510342ec4ce85df11ccfa3df06bbb2Michael Trimarchi 10701ab10393c510342ec4ce85df11ccfa3df06bbb2Michael Trimarchi#ifdef CONFIG_SH_DSP 10801ab10393c510342ec4ce85df11ccfa3df06bbb2Michael Trimarchi /* Dsp status information */ 10901ab10393c510342ec4ce85df11ccfa3df06bbb2Michael Trimarchi struct sh_dsp_struct dsp_status; 11001ab10393c510342ec4ce85df11ccfa3df06bbb2Michael Trimarchi#endif 111af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt 1120ea820cf9bf58f735ed40ec67947159c4f170012Paul Mundt /* Extended processor state */ 1130ea820cf9bf58f735ed40ec67947159c4f170012Paul Mundt union thread_xstate *xstate; 114af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt}; 115af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt 116af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt#define INIT_THREAD { \ 117af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt .sp = sizeof(init_stack) + (long) &init_stack, \ 11894ea5e449ae834af058ef005d16a8ad44fcf13d6Paul Mundt .flags = 0, \ 119af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt} 120af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt 121af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt/* Forward declaration, a strange C thing */ 122af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundtstruct task_struct; 12370e068eef97d05c97c3512f82352f39fdadfa8cbPaul Mundt 12470e068eef97d05c97c3512f82352f39fdadfa8cbPaul Mundtextern void start_thread(struct pt_regs *regs, unsigned long new_pc, unsigned long new_sp); 125af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt 126af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt/* Free all resources held by a thread. */ 127af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundtextern void release_thread(struct task_struct *); 128af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt 129af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt/* Prepare to copy thread state - unlazy all lazy status */ 130d3ea9fa0a563620fe9f416f94bb8927c64390917Stuart Menefyvoid prepare_to_copy(struct task_struct *tsk); 131af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt 132af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt/* 133af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt * create a kernel thread without removing it from tasklists 134af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt */ 135af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundtextern int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags); 136af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt 137af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt/* Copy and release all segment info associated with a VM */ 138af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt#define copy_segments(p, mm) do { } while(0) 139af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt#define release_segments(mm) do { } while(0) 140af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt 141af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt/* 142af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt * FPU lazy state save handling. 143af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt */ 144af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt 145af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundtstatic __inline__ void disable_fpu(void) 146af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt{ 147af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt unsigned long __dummy; 148af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt 149af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt /* Set FD flag in SR */ 150af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt __asm__ __volatile__("stc sr, %0\n\t" 151af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt "or %1, %0\n\t" 152af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt "ldc %0, sr" 153af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt : "=&r" (__dummy) 154af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt : "r" (SR_FD)); 155af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt} 156af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt 157af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundtstatic __inline__ void enable_fpu(void) 158af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt{ 159af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt unsigned long __dummy; 160af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt 161af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt /* Clear out FD flag in SR */ 162af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt __asm__ __volatile__("stc sr, %0\n\t" 163af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt "and %1, %0\n\t" 164af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt "ldc %0, sr" 165af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt : "=&r" (__dummy) 166af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt : "r" (~SR_FD)); 167af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt} 168af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt 169af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt/* Double presision, NANS as NANS, rounding to nearest, no exceptions */ 170af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt#define FPSCR_INIT 0x00080000 171af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt 172af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt#define FPSCR_CAUSE_MASK 0x0001f000 /* Cause bits */ 173af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt#define FPSCR_FLAG_MASK 0x0000007c /* Flag bits */ 174af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt 175af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt/* 176af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt * Return saved PC of a blocked thread. 177af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt */ 178af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt#define thread_saved_pc(tsk) (tsk->thread.pc) 179af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt 180af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundtvoid show_trace(struct task_struct *tsk, unsigned long *sp, 181af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt struct pt_regs *regs); 1825d2685d0b3edc51ecc92604d5b7f5ca9b29b90bbPaul Mundt 1835d2685d0b3edc51ecc92604d5b7f5ca9b29b90bbPaul Mundt#ifdef CONFIG_DUMP_CODE 1849cfc9a9b6fff9ea7a19814b4472b3cb18b7bbdccPaul Mundtvoid show_code(struct pt_regs *regs); 1855d2685d0b3edc51ecc92604d5b7f5ca9b29b90bbPaul Mundt#else 1865d2685d0b3edc51ecc92604d5b7f5ca9b29b90bbPaul Mundtstatic inline void show_code(struct pt_regs *regs) 1875d2685d0b3edc51ecc92604d5b7f5ca9b29b90bbPaul Mundt{ 1885d2685d0b3edc51ecc92604d5b7f5ca9b29b90bbPaul Mundt} 1895d2685d0b3edc51ecc92604d5b7f5ca9b29b90bbPaul Mundt#endif 1905d2685d0b3edc51ecc92604d5b7f5ca9b29b90bbPaul Mundt 191af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundtextern unsigned long get_wchan(struct task_struct *p); 192af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt 193af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt#define KSTK_EIP(tsk) (task_pt_regs(tsk)->pc) 194af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt#define KSTK_ESP(tsk) (task_pt_regs(tsk)->regs[15]) 195af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt 196a73090ffaf0f6853880d9ac3fff7e5d88215131aPaul Mundt#if defined(CONFIG_CPU_SH2A) || defined(CONFIG_CPU_SH4) 197c81fc389255d287dbfb17a70cd172663f962341aPaul Mundt 198af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt#define PREFETCH_STRIDE L1_CACHE_BYTES 199af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt#define ARCH_HAS_PREFETCH 200af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt#define ARCH_HAS_PREFETCHW 201c81fc389255d287dbfb17a70cd172663f962341aPaul Mundt 202c81fc389255d287dbfb17a70cd172663f962341aPaul Mundtstatic inline void prefetch(const void *x) 203af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt{ 204d53e4307c2f3856167407a1d9b8f8fa001286066Giuseppe CAVALLARO __builtin_prefetch(x, 0, 3); 205af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt} 206af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt 207c81fc389255d287dbfb17a70cd172663f962341aPaul Mundtstatic inline void prefetchw(const void *x) 208d53e4307c2f3856167407a1d9b8f8fa001286066Giuseppe CAVALLARO{ 209d53e4307c2f3856167407a1d9b8f8fa001286066Giuseppe CAVALLARO __builtin_prefetch(x, 1, 3); 210d53e4307c2f3856167407a1d9b8f8fa001286066Giuseppe CAVALLARO} 211af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt#endif 212af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt 213af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt#endif /* __KERNEL__ */ 214af3c7dfe822b598a2f977098101ed8b63cf0fdd1Paul Mundt#endif /* __ASM_SH_PROCESSOR_32_H */ 215