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
16 * Default implementation of macro that returns current
17 * instruction pointer ("program counter").
19 #define current_text_addr() ({ __label__ _l; _l: &&_l; })
21 #include <linux/compiler.h>
22 #include <asm/segment.h>
23 #include <asm/ptrace.h>
24 #include <asm/current.h>
26 static inline unsigned long rdusp(void)
28 extern unsigned int _sw_usp
;
33 static inline void wrusp(unsigned long usp
)
35 extern unsigned int _sw_usp
;
41 * User space process size: 3.75GB. This is hardcoded into a few places,
42 * so don't change it unless you know what you are doing.
44 #define TASK_SIZE (0xFFFFFFFFUL)
47 #define STACK_TOP TASK_SIZE
48 #define STACK_TOP_MAX STACK_TOP
52 * This decides where the kernel will search for a free chunk of vm
53 * space during mmap's. We won't be using it
55 #define TASK_UNMAPPED_BASE 0
57 struct thread_struct
{
58 unsigned long ksp
; /* kernel stack pointer */
59 unsigned long usp
; /* user stack pointer */
60 unsigned long ccr
; /* saved status register */
61 unsigned long esp0
; /* points to SR of stack frame */
68 #define INIT_THREAD { \
69 .ksp = sizeof(init_stack) + (unsigned long)init_stack, \
74 .addr = (unsigned short *)-1, \
80 * Do necessary setup to start up a newly executed thread.
82 * pass the data segment into user programs if it exists,
83 * it can't hurt anything as far as I can tell
85 #if defined(CONFIG_CPU_H8300H)
86 #define start_thread(_regs, _pc, _usp) \
88 (_regs)->pc = (_pc); \
89 (_regs)->ccr = 0x00; /* clear all flags */ \
90 (_regs)->er5 = current->mm->start_data; /* GOT base */ \
91 (_regs)->sp = ((unsigned long)(_usp)) - sizeof(unsigned long) * 3; \
94 #if defined(CONFIG_CPU_H8S)
95 #define start_thread(_regs, _pc, _usp) \
97 (_regs)->pc = (_pc); \
98 (_regs)->ccr = 0x00; /* clear kernel flag */ \
99 (_regs)->exr = 0x78; /* enable all interrupts */ \
100 (_regs)->er5 = current->mm->start_data; /* GOT base */ \
101 /* 14 = space for retaddr(4), vector(4), er0(4) and exr(2) on stack */ \
102 (_regs)->sp = ((unsigned long)(_usp)) - 14; \
106 /* Forward declaration, a strange C thing */
109 /* Free all resources held by a thread. */
110 static inline void release_thread(struct task_struct
*dead_task
)
114 unsigned long get_wchan(struct task_struct
*p
);
116 #define KSTK_EIP(tsk) \
118 unsigned long eip = 0; \
119 if ((tsk)->thread.esp0 > PAGE_SIZE && \
120 MAP_NR((tsk)->thread.esp0) < max_mapnr) \
121 eip = ((struct pt_regs *) (tsk)->thread.esp0)->pc; \
124 #define KSTK_ESP(tsk) ((tsk) == current ? rdusp() : (tsk)->thread.usp)
126 #define cpu_relax() barrier()
128 #define HARD_RESET_NOW() ({ \
129 local_irq_disable(); \