forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-10 10ebd8556b7990499c896a550e3d416b444211e6
kernel/arch/arm/include/asm/ptrace.h
....@@ -1,11 +1,8 @@
1
+/* SPDX-License-Identifier: GPL-2.0-only */
12 /*
23 * arch/arm/include/asm/ptrace.h
34 *
45 * Copyright (C) 1996-2003 Russell King
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 as
8
- * published by the Free Software Foundation.
96 */
107 #ifndef __ASM_ARM_PTRACE_H
118 #define __ASM_ARM_PTRACE_H
....@@ -167,5 +164,31 @@
167164 ((current_stack_pointer | (THREAD_SIZE - 1)) - 7) - 1; \
168165 })
169166
167
+
168
+/*
169
+ * Update ITSTATE after normal execution of an IT block instruction.
170
+ *
171
+ * The 8 IT state bits are split into two parts in CPSR:
172
+ * ITSTATE<1:0> are in CPSR<26:25>
173
+ * ITSTATE<7:2> are in CPSR<15:10>
174
+ */
175
+static inline unsigned long it_advance(unsigned long cpsr)
176
+{
177
+ if ((cpsr & 0x06000400) == 0) {
178
+ /* ITSTATE<2:0> == 0 means end of IT block, so clear IT state */
179
+ cpsr &= ~PSR_IT_MASK;
180
+ } else {
181
+ /* We need to shift left ITSTATE<4:0> */
182
+ const unsigned long mask = 0x06001c00; /* Mask ITSTATE<4:0> */
183
+ unsigned long it = cpsr & mask;
184
+ it <<= 1;
185
+ it |= it >> (27 - 10); /* Carry ITSTATE<2> to correct place */
186
+ it &= mask;
187
+ cpsr &= ~mask;
188
+ cpsr |= it;
189
+ }
190
+ return cpsr;
191
+}
192
+
170193 #endif /* __ASSEMBLY__ */
171194 #endif