Merge branch 'x86-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel...
[sfrench/cifs-2.6.git] / arch / cris / include / arch-v10 / arch / processor.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __ASM_CRIS_ARCH_PROCESSOR_H
3 #define __ASM_CRIS_ARCH_PROCESSOR_H
4
5 /*
6  * Default implementation of macro that returns current
7  * instruction pointer ("program counter").
8  */
9 #define current_text_addr() ({void *pc; __asm__ ("move.d $pc,%0" : "=rm" (pc)); pc; })
10
11 /* CRIS has no problems with write protection */
12 #define wp_works_ok 1
13
14 /* CRIS thread_struct. this really has nothing to do with the processor itself, since
15  * CRIS does not do any hardware task-switching, but it's here for legacy reasons.
16  * The thread_struct here is used when task-switching using _resume defined in entry.S.
17  * The offsets here are hardcoded into _resume - if you change this struct, you need to
18  * change them as well!!!
19 */
20
21 struct thread_struct {
22         unsigned long ksp;     /* kernel stack pointer */
23         unsigned long usp;     /* user stack pointer */
24         unsigned long dccr;    /* saved flag register */
25 };
26
27 /*
28  * User space process size. This is hardcoded into a few places,
29  * so don't change it unless you know what you are doing.
30  */
31
32 #ifdef CONFIG_CRIS_LOW_MAP
33 #define TASK_SIZE       (0x50000000UL)   /* 1.25 GB */
34 #else
35 #define TASK_SIZE       (0xA0000000UL)   /* 2.56 GB */
36 #endif
37
38 #define INIT_THREAD  { \
39    0, 0, 0x20 }  /* ccr = int enable, nothing else */
40
41 #define KSTK_EIP(tsk)   \
42 ({                      \
43         unsigned long eip = 0;   \
44         unsigned long regs = (unsigned long)task_pt_regs(tsk); \
45         if (regs > PAGE_SIZE && \
46                 virt_addr_valid(regs)) \
47         eip = ((struct pt_regs *)regs)->irp; \
48         eip; \
49 })
50
51 /* give the thread a program location
52  * set user-mode (The 'U' flag (User mode flag) is CCR/DCCR bit 8) 
53  * switch user-stackpointer
54  */
55
56 #define start_thread(regs, ip, usp) do { \
57         regs->irp = ip;       \
58         regs->dccr |= 1 << U_DCCR_BITNR; \
59         wrusp(usp);           \
60 } while(0)
61
62 /* Called when handling a kernel bus fault fixup.
63  *
64  * After a fixup we do not want to return by restoring the CPU-state
65  * anymore, so switch frame-types (see ptrace.h)
66  */
67 #define arch_fixup(regs) \
68    regs->frametype = CRIS_FRAME_NORMAL;
69
70 #endif