1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* include/asm/processor.h
4 * Copyright (C) 1994 David S. Miller (davem@caip.rutgers.edu)
7 #ifndef __ASM_SPARC_PROCESSOR_H
8 #define __ASM_SPARC_PROCESSOR_H
11 * Sparc32 implementation of macro that returns current
12 * instruction pointer ("program counter").
14 #define current_text_addr() ({ void *pc; __asm__("sethi %%hi(1f), %0; or %0, %%lo(1f), %0;\n1:" : "=r" (pc)); pc; })
17 #include <asm/ptrace.h>
19 #include <asm/signal.h>
22 /* Whee, this is STACK_TOP + PAGE_SIZE and the lowest kernel address too...
23 * That one page is used to protect kernel from intruders, so that
24 * we can make our access_ok test faster
26 #define TASK_SIZE PAGE_OFFSET
28 #define STACK_TOP (PAGE_OFFSET - PAGE_SIZE)
29 #define STACK_TOP_MAX STACK_TOP
30 #endif /* __KERNEL__ */
36 unsigned long *insn_addr
;
45 /* The Sparc processor specific thread struct. */
46 struct thread_struct
{
47 struct pt_regs
*kregs
;
50 /* Special child fork kpsr/kwim values. */
51 unsigned long fork_kpsr
__attribute__ ((aligned (8)));
52 unsigned long fork_kwim
;
54 /* Floating point regs */
55 unsigned long float_regs
[32] __attribute__ ((aligned (8)));
57 unsigned long fpqdepth
;
58 struct fpq fpqueue
[16];
60 mm_segment_t current_ds
;
63 #define SPARC_FLAG_KTHREAD 0x1 /* task is a kernel thread */
64 #define SPARC_FLAG_UNALIGNED 0x2 /* is allowed to do unaligned accesses */
66 #define INIT_THREAD { \
67 .flags = SPARC_FLAG_KTHREAD, \
68 .current_ds = KERNEL_DS, \
71 /* Do necessary setup to start up a newly executed thread. */
72 static inline void start_thread(struct pt_regs
* regs
, unsigned long pc
,
75 register unsigned long zero
asm("g1");
77 regs
->psr
= (regs
->psr
& (PSR_CWP
)) | PSR_S
;
78 regs
->pc
= ((pc
& (~3)) - 4);
79 regs
->npc
= regs
->pc
+ 4;
82 __asm__
__volatile__("std\t%%g0, [%0 + %3 + 0x00]\n\t"
83 "std\t%%g0, [%0 + %3 + 0x08]\n\t"
84 "std\t%%g0, [%0 + %3 + 0x10]\n\t"
85 "std\t%%g0, [%0 + %3 + 0x18]\n\t"
86 "std\t%%g0, [%0 + %3 + 0x20]\n\t"
87 "std\t%%g0, [%0 + %3 + 0x28]\n\t"
88 "std\t%%g0, [%0 + %3 + 0x30]\n\t"
89 "st\t%1, [%0 + %3 + 0x38]\n\t"
90 "st\t%%g0, [%0 + %3 + 0x3c]"
93 "r" (sp
- sizeof(struct reg_window32
)),
95 "i" ((const unsigned long)(&((struct pt_regs
*)0)->u_regs
[0]))
99 /* Free all resources held by a thread. */
100 #define release_thread(tsk) do { } while(0)
102 unsigned long get_wchan(struct task_struct
*);
104 #define task_pt_regs(tsk) ((tsk)->thread.kregs)
105 #define KSTK_EIP(tsk) ((tsk)->thread.kregs->pc)
106 #define KSTK_ESP(tsk) ((tsk)->thread.kregs->u_regs[UREG_FP])
110 extern struct task_struct
*last_task_used_math
;
111 int do_mathemu(struct pt_regs
*regs
, struct task_struct
*fpt
);
113 #define cpu_relax() barrier()
115 extern void (*sparc_idle
)(void);
119 #endif /* __ASM_SPARC_PROCESSOR_H */