linux/arch/nds32/include/asm/processor.h
<<
>>
Prefs
   1/* SPDX-License-Identifier: GPL-2.0 */
   2// Copyright (C) 2005-2017 Andes Technology Corporation
   3
   4#ifndef __ASM_NDS32_PROCESSOR_H
   5#define __ASM_NDS32_PROCESSOR_H
   6
   7#ifdef __KERNEL__
   8
   9#include <asm/ptrace.h>
  10#include <asm/types.h>
  11#include <asm/sigcontext.h>
  12
  13#define KERNEL_STACK_SIZE       PAGE_SIZE
  14#define STACK_TOP       TASK_SIZE
  15#define STACK_TOP_MAX   TASK_SIZE
  16
  17struct cpu_context {
  18        unsigned long r6;
  19        unsigned long r7;
  20        unsigned long r8;
  21        unsigned long r9;
  22        unsigned long r10;
  23        unsigned long r11;
  24        unsigned long r12;
  25        unsigned long r13;
  26        unsigned long r14;
  27        unsigned long fp;
  28        unsigned long pc;
  29        unsigned long sp;
  30};
  31
  32struct thread_struct {
  33        struct cpu_context cpu_context; /* cpu context */
  34        /* fault info     */
  35        unsigned long address;
  36        unsigned long trap_no;
  37        unsigned long error_code;
  38
  39        struct fpu_struct fpu;
  40};
  41
  42#define INIT_THREAD  {  }
  43
  44#ifdef __NDS32_EB__
  45#define PSW_DE  PSW_mskBE
  46#else
  47#define PSW_DE  0x0
  48#endif
  49
  50#ifdef CONFIG_WBNA
  51#define PSW_valWBNA     PSW_mskWBNA
  52#else
  53#define PSW_valWBNA     0x0
  54#endif
  55
  56#ifdef CONFIG_HWZOL
  57#define PSW_valINIT (PSW_CPL_ANY | PSW_mskAEN | PSW_valWBNA | PSW_mskDT | PSW_mskIT | PSW_DE | PSW_mskGIE)
  58#else
  59#define PSW_valINIT (PSW_CPL_ANY | PSW_valWBNA | PSW_mskDT | PSW_mskIT | PSW_DE | PSW_mskGIE)
  60#endif
  61
  62#define start_thread(regs,pc,stack)                     \
  63({                                                      \
  64        memzero(regs, sizeof(struct pt_regs));          \
  65        forget_syscall(regs);                           \
  66        regs->ipsw = PSW_valINIT;                       \
  67        regs->ir0 = (PSW_CPL_ANY | PSW_valWBNA | PSW_mskDT | PSW_mskIT | PSW_DE | PSW_SYSTEM | PSW_INTL_1);     \
  68        regs->ipc = pc;                                 \
  69        regs->sp = stack;                               \
  70})
  71
  72/* Forward declaration, a strange C thing */
  73struct task_struct;
  74
  75/* Free all resources held by a thread. */
  76#define release_thread(thread) do { } while(0)
  77#if IS_ENABLED(CONFIG_FPU)
  78#if !IS_ENABLED(CONFIG_UNLAZU_FPU)
  79extern struct task_struct *last_task_used_math;
  80#endif
  81#endif
  82
  83/* Prepare to copy thread state - unlazy all lazy status */
  84#define prepare_to_copy(tsk)    do { } while (0)
  85
  86unsigned long get_wchan(struct task_struct *p);
  87
  88#define cpu_relax()                     barrier()
  89
  90#define task_pt_regs(task) \
  91        ((struct pt_regs *) (task_stack_page(task) + THREAD_SIZE \
  92                - 8) - 1)
  93
  94/*
  95 * Create a new kernel thread
  96 */
  97extern int kernel_thread(int (*fn) (void *), void *arg, unsigned long flags);
  98
  99#define KSTK_EIP(tsk)   instruction_pointer(task_pt_regs(tsk))
 100#define KSTK_ESP(tsk)   user_stack_pointer(task_pt_regs(tsk))
 101
 102#endif
 103
 104#endif /* __ASM_NDS32_PROCESSOR_H */
 105