summaryrefslogtreecommitdiffstats
path: root/arch/nds32/include/asm/processor.h
blob: 9c83caf4269f52314c3d35550628d91f29053c70 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
// SPDX-License-Identifier: GPL-2.0
// Copyright (C) 2005-2017 Andes Technology Corporation

#ifndef __ASM_NDS32_PROCESSOR_H
#define __ASM_NDS32_PROCESSOR_H

/*
 * Default implementation of macro that returns current
 * instruction pointer ("program counter").
 */
#define current_text_addr() ({ __label__ _l; _l: &&_l;})

#ifdef __KERNEL__

#include <asm/ptrace.h>
#include <asm/types.h>
#include <asm/sigcontext.h>

#define KERNEL_STACK_SIZE	PAGE_SIZE
#define STACK_TOP	TASK_SIZE
#define STACK_TOP_MAX   TASK_SIZE

struct cpu_context {
	unsigned long r6;
	unsigned long r7;
	unsigned long r8;
	unsigned long r9;
	unsigned long r10;
	unsigned long r11;
	unsigned long r12;
	unsigned long r13;
	unsigned long r14;
	unsigned long fp;
	unsigned long pc;
	unsigned long sp;
};

struct thread_struct {
	struct cpu_context cpu_context;	/* cpu context */
	/* fault info     */
	unsigned long address;
	unsigned long trap_no;
	unsigned long error_code;
};

#define INIT_THREAD  {	}

#ifdef __NDS32_EB__
#define PSW_DE	PSW_mskBE
#else
#define PSW_DE	0x0
#endif

#ifdef CONFIG_WBNA
#define PSW_valWBNA	PSW_mskWBNA
#else
#define PSW_valWBNA	0x0
#endif

#ifdef CONFIG_HWZOL
#define	PSW_valINIT (PSW_CPL_ANY | PSW_mskAEN | PSW_valWBNA | PSW_mskDT | PSW_mskIT | PSW_DE | PSW_mskGIE)
#else
#define	PSW_valINIT (PSW_CPL_ANY | PSW_valWBNA | PSW_mskDT | PSW_mskIT | PSW_DE | PSW_mskGIE)
#endif

#define start_thread(regs,pc,stack)			\
({							\
	memzero(regs, sizeof(struct pt_regs));		\
	forget_syscall(regs);				\
	regs->ipsw = PSW_valINIT;			\
	regs->ir0 = (PSW_CPL_ANY | PSW_valWBNA | PSW_mskDT | PSW_mskIT | PSW_DE | PSW_SYSTEM | PSW_INTL_1);	\
	regs->ipc = pc;					\
	regs->sp = stack;				\
})

/* Forward declaration, a strange C thing */
struct task_struct;

/* Free all resources held by a thread. */
#define release_thread(thread) do { } while(0)

/* Prepare to copy thread state - unlazy all lazy status */
#define prepare_to_copy(tsk)	do { } while (0)

unsigned long get_wchan(struct task_struct *p);

#define cpu_relax()			barrier()

#define task_pt_regs(task) \
	((struct pt_regs *) (task_stack_page(task) + THREAD_SIZE \
		- 8) - 1)

/*
 * Create a new kernel thread
 */
extern int kernel_thread(int (*fn) (void *), void *arg, unsigned long flags);

#define KSTK_EIP(tsk)	instruction_pointer(task_pt_regs(tsk))
#define KSTK_ESP(tsk)	user_stack_pointer(task_pt_regs(tsk))

#endif

#endif /* __ASM_NDS32_PROCESSOR_H */