1 /* SPDX-License-Identifier: GPL-2.0 */
3 * include/asm-h8300/processor.h
5 * Copyright (C) 2002 Yoshinori Sato
7 * Based on: linux/asm-m68nommu/processor.h
9 * Copyright (C) 1995 Hamish Macdonald
12 #ifndef __ASM_H8300_PROCESSOR_H
13 #define __ASM_H8300_PROCESSOR_H
15 #include <linux/compiler.h>
16 #include <asm/segment.h>
17 #include <asm/ptrace.h>
18 #include <asm/current.h>
20 static inline unsigned long rdusp(void)
22 extern unsigned int _sw_usp
;
27 static inline void wrusp(unsigned long usp
)
29 extern unsigned int _sw_usp
;
35 * User space process size: 3.75GB. This is hardcoded into a few places,
36 * so don't change it unless you know what you are doing.
38 #define TASK_SIZE (0xFFFFFFFFUL)
41 #define STACK_TOP TASK_SIZE
42 #define STACK_TOP_MAX STACK_TOP
46 * This decides where the kernel will search for a free chunk of vm
47 * space during mmap's. We won't be using it
49 #define TASK_UNMAPPED_BASE 0
51 struct thread_struct
{
52 unsigned long ksp
; /* kernel stack pointer */
53 unsigned long usp
; /* user stack pointer */
54 unsigned long ccr
; /* saved status register */
55 unsigned long esp0
; /* points to SR of stack frame */
62 #define INIT_THREAD { \
63 .ksp = sizeof(init_stack) + (unsigned long)init_stack, \
68 .addr = (unsigned short *)-1, \
74 * Do necessary setup to start up a newly executed thread.
76 * pass the data segment into user programs if it exists,
77 * it can't hurt anything as far as I can tell
79 #if defined(CONFIG_CPU_H8300H)
80 #define start_thread(_regs, _pc, _usp) \
82 (_regs)->pc = (_pc); \
83 (_regs)->ccr = 0x00; /* clear all flags */ \
84 (_regs)->er5 = current->mm->start_data; /* GOT base */ \
85 (_regs)->sp = ((unsigned long)(_usp)) - sizeof(unsigned long) * 3; \
88 #if defined(CONFIG_CPU_H8S)
89 #define start_thread(_regs, _pc, _usp) \
91 (_regs)->pc = (_pc); \
92 (_regs)->ccr = 0x00; /* clear kernel flag */ \
93 (_regs)->exr = 0x78; /* enable all interrupts */ \
94 (_regs)->er5 = current->mm->start_data; /* GOT base */ \
95 /* 14 = space for retaddr(4), vector(4), er0(4) and exr(2) on stack */ \
96 (_regs)->sp = ((unsigned long)(_usp)) - 14; \
100 /* Forward declaration, a strange C thing */
103 /* Free all resources held by a thread. */
104 static inline void release_thread(struct task_struct
*dead_task
)
108 unsigned long get_wchan(struct task_struct
*p
);
110 #define KSTK_EIP(tsk) \
112 unsigned long eip = 0; \
113 if ((tsk)->thread.esp0 > PAGE_SIZE && \
114 MAP_NR((tsk)->thread.esp0) < max_mapnr) \
115 eip = ((struct pt_regs *) (tsk)->thread.esp0)->pc; \
118 #define KSTK_ESP(tsk) ((tsk) == current ? rdusp() : (tsk)->thread.usp)
120 #define cpu_relax() barrier()
122 #define HARD_RESET_NOW() ({ \
123 local_irq_disable(); \