Loading...
1/*
2 * Process/processor support for the Hexagon architecture
3 *
4 * Copyright (c) 2010-2012, The Linux Foundation. All rights reserved.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 and
8 * only version 2 as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 * 02110-1301, USA.
19 */
20
21#ifndef _ASM_PROCESSOR_H
22#define _ASM_PROCESSOR_H
23
24#ifndef __ASSEMBLY__
25
26#include <asm/mem-layout.h>
27#include <asm/registers.h>
28#include <asm/hexagon_vm.h>
29
30/* must be a macro */
31#define current_text_addr() ({ __label__ _l; _l: &&_l; })
32
33/* task_struct, defined elsewhere, is the "process descriptor" */
34struct task_struct;
35
36extern void start_thread(struct pt_regs *, unsigned long, unsigned long);
37
38/*
39 * thread_struct is supposed to be for context switch data.
40 * Specifically, to hold the state necessary to perform switch_to...
41 */
42struct thread_struct {
43 void *switch_sp;
44};
45
46/*
47 * initializes thread_struct
48 * The only thing we have in there is switch_sp
49 * which doesn't really need to be initialized.
50 */
51
52#define INIT_THREAD { \
53}
54
55#define cpu_relax() __vmyield()
56
57/*
58 * Decides where the kernel will search for a free chunk of vm space during
59 * mmaps.
60 * See also arch_get_unmapped_area.
61 * Doesn't affect if you have MAX_FIXED in the page flags set though...
62 *
63 * Apparently the convention is that ld.so will ask for "unmapped" private
64 * memory to be allocated SOMEWHERE, but it also asks for memory explicitly
65 * via MAP_FIXED at the lower * addresses starting at VA=0x0.
66 *
67 * If the two requests collide, you get authentic segfaulting action, so
68 * you have to kick the "unmapped" base requests higher up.
69 */
70#define TASK_UNMAPPED_BASE (PAGE_ALIGN(TASK_SIZE/3))
71
72
73#define task_pt_regs(task) \
74 ((struct pt_regs *)(task_stack_page(task) + THREAD_SIZE) - 1)
75
76#define KSTK_EIP(tsk) (pt_elr(task_pt_regs(tsk)))
77#define KSTK_ESP(tsk) (pt_psp(task_pt_regs(tsk)))
78
79/* Free all resources held by a thread; defined in process.c */
80extern void release_thread(struct task_struct *dead_task);
81
82/* Get wait channel for task P. */
83extern unsigned long get_wchan(struct task_struct *p);
84
85/* The following stuff is pretty HEXAGON specific. */
86
87/* This is really just here for __switch_to.
88 Offsets are pulled via asm-offsets.c */
89
90/*
91 * No real reason why VM and native switch stacks should be different.
92 * Ultimately this should merge. Note that Rev C. ABI called out only
93 * R24-27 as callee saved GPRs needing explicit attention (R29-31 being
94 * dealt with automagically by allocframe), but the current ABI has
95 * more, R16-R27. By saving more, the worst case is that we waste some
96 * cycles if building with the old compilers.
97 */
98
99struct hexagon_switch_stack {
100 union {
101 struct {
102 unsigned long r16;
103 unsigned long r17;
104 };
105 unsigned long long r1716;
106 };
107 union {
108 struct {
109 unsigned long r18;
110 unsigned long r19;
111 };
112 unsigned long long r1918;
113 };
114 union {
115 struct {
116 unsigned long r20;
117 unsigned long r21;
118 };
119 unsigned long long r2120;
120 };
121 union {
122 struct {
123 unsigned long r22;
124 unsigned long r23;
125 };
126 unsigned long long r2322;
127 };
128 union {
129 struct {
130 unsigned long r24;
131 unsigned long r25;
132 };
133 unsigned long long r2524;
134 };
135 union {
136 struct {
137 unsigned long r26;
138 unsigned long r27;
139 };
140 unsigned long long r2726;
141 };
142
143 unsigned long fp;
144 unsigned long lr;
145};
146
147#endif /* !__ASSEMBLY__ */
148
149#endif
1/* SPDX-License-Identifier: GPL-2.0-only */
2/*
3 * Process/processor support for the Hexagon architecture
4 *
5 * Copyright (c) 2010-2012, The Linux Foundation. All rights reserved.
6 */
7
8#ifndef _ASM_PROCESSOR_H
9#define _ASM_PROCESSOR_H
10
11#ifndef __ASSEMBLY__
12
13#include <asm/mem-layout.h>
14#include <asm/registers.h>
15#include <asm/hexagon_vm.h>
16
17/* task_struct, defined elsewhere, is the "process descriptor" */
18struct task_struct;
19
20extern void start_thread(struct pt_regs *, unsigned long, unsigned long);
21
22/*
23 * thread_struct is supposed to be for context switch data.
24 * Specifically, to hold the state necessary to perform switch_to...
25 */
26struct thread_struct {
27 void *switch_sp;
28};
29
30/*
31 * initializes thread_struct
32 * The only thing we have in there is switch_sp
33 * which doesn't really need to be initialized.
34 */
35
36#define INIT_THREAD { \
37}
38
39#define cpu_relax() __vmyield()
40
41/*
42 * Decides where the kernel will search for a free chunk of vm space during
43 * mmaps.
44 * See also arch_get_unmapped_area.
45 * Doesn't affect if you have MAX_FIXED in the page flags set though...
46 *
47 * Apparently the convention is that ld.so will ask for "unmapped" private
48 * memory to be allocated SOMEWHERE, but it also asks for memory explicitly
49 * via MAP_FIXED at the lower * addresses starting at VA=0x0.
50 *
51 * If the two requests collide, you get authentic segfaulting action, so
52 * you have to kick the "unmapped" base requests higher up.
53 */
54#define TASK_UNMAPPED_BASE (PAGE_ALIGN(TASK_SIZE/3))
55
56
57#define task_pt_regs(task) \
58 ((struct pt_regs *)(task_stack_page(task) + THREAD_SIZE) - 1)
59
60#define KSTK_EIP(tsk) (pt_elr(task_pt_regs(tsk)))
61#define KSTK_ESP(tsk) (pt_psp(task_pt_regs(tsk)))
62
63extern unsigned long __get_wchan(struct task_struct *p);
64
65/* The following stuff is pretty HEXAGON specific. */
66
67/* This is really just here for __switch_to.
68 Offsets are pulled via asm-offsets.c */
69
70/*
71 * No real reason why VM and native switch stacks should be different.
72 * Ultimately this should merge. Note that Rev C. ABI called out only
73 * R24-27 as callee saved GPRs needing explicit attention (R29-31 being
74 * dealt with automagically by allocframe), but the current ABI has
75 * more, R16-R27. By saving more, the worst case is that we waste some
76 * cycles if building with the old compilers.
77 */
78
79struct hexagon_switch_stack {
80 union {
81 struct {
82 unsigned long r16;
83 unsigned long r17;
84 };
85 unsigned long long r1716;
86 };
87 union {
88 struct {
89 unsigned long r18;
90 unsigned long r19;
91 };
92 unsigned long long r1918;
93 };
94 union {
95 struct {
96 unsigned long r20;
97 unsigned long r21;
98 };
99 unsigned long long r2120;
100 };
101 union {
102 struct {
103 unsigned long r22;
104 unsigned long r23;
105 };
106 unsigned long long r2322;
107 };
108 union {
109 struct {
110 unsigned long r24;
111 unsigned long r25;
112 };
113 unsigned long long r2524;
114 };
115 union {
116 struct {
117 unsigned long r26;
118 unsigned long r27;
119 };
120 unsigned long long r2726;
121 };
122
123 unsigned long fp;
124 unsigned long lr;
125};
126
127#endif /* !__ASSEMBLY__ */
128
129#endif