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