disable sstrip when using musl
[lede.git] / target / linux / ubicom32 / files / arch / ubicom32 / include / asm / range-protect-asm.h
1 /*
2  * arch/ubicom32/include/asm/range-protect-asm.h
3  *   Assembly macros for enabling memory protection.
4  *
5  * (C) Copyright 2009, Ubicom, Inc.
6  *
7  * This file is part of the Ubicom32 Linux Kernel Port.
8  *
9  * The Ubicom32 Linux Kernel Port is free software: you can redistribute
10  * it and/or modify it under the terms of the GNU General Public License
11  * as published by the Free Software Foundation, either version 2 of the
12  * License, or (at your option) any later version.
13  *
14  * The Ubicom32 Linux Kernel Port is distributed in the hope that it
15  * will be useful, but WITHOUT ANY WARRANTY; without even the implied
16  * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
17  * the GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with the Ubicom32 Linux Kernel Port.  If not,
21  * see <http://www.gnu.org/licenses/>.
22  *
23  * Ubicom32 implementation derived from (with many thanks):
24  *   arch/m68knommu
25  *   arch/blackfin
26  *   arch/parisc
27  */
28
29 #ifndef _ASM_UBICOM32_RANGE_PROTECT_ASM_H
30 #define _ASM_UBICOM32_RANGE_PROTECT_ASM_H
31
32 #if defined(__ASSEMBLY__)
33
34 #include <asm/thread-asm.h>
35
36 /*
37  * You should only use the enable/disable ranges when you have the atomic lock,
38  * if you do not there will be problems.
39  */
40
41 /*
42  * enable_kernel_ranges
43  *      Enable the kernel ranges (disabling protection) for thread,
44  *      where thread == (1 << thread number)
45  */
46 .macro  enable_kernel_ranges thread
47 #ifdef CONFIG_PROTECT_KERNEL
48         or.4    I_RANGE0_EN, I_RANGE0_EN, \thread        /* Enable Range Register */
49         or.4    D_RANGE0_EN, D_RANGE0_EN, \thread
50         or.4    D_RANGE1_EN, D_RANGE1_EN, \thread
51 #endif
52 .endm
53
54 /*
55  * enable_kernel_ranges_for_current
56  *      Enable the kernel ranges (disabling protection) for this thread
57  */
58 .macro  enable_kernel_ranges_for_current scratch_reg
59 #ifdef CONFIG_PROTECT_KERNEL
60         thread_get_self_mask \scratch_reg
61         enable_kernel_ranges \scratch_reg
62 #endif
63 .endm
64
65 /*
66  * disable_kernel_ranges
67  *      Disables the kernel ranges (enabling protection) for thread
68  *      where thread == (1 << thread number)
69  */
70 .macro  disable_kernel_ranges thread
71 #ifdef CONFIG_PROTECT_KERNEL
72         not.4   \thread, \thread
73         and.4   I_RANGE0_EN, I_RANGE0_EN, \thread        /* Disable Range Register */
74         and.4   D_RANGE0_EN, D_RANGE0_EN, \thread
75         and.4   D_RANGE1_EN, D_RANGE1_EN, \thread
76 #endif
77 .endm
78
79 /*
80  * disable_kernel_ranges_for_current
81  *      Disable kernel ranges (enabling protection) for this thread
82  */
83 .macro  disable_kernel_ranges_for_current scratch_reg
84 #ifdef CONFIG_PROTECT_KERNEL
85         thread_get_self_mask \scratch_reg
86         disable_kernel_ranges \scratch_reg
87 #endif
88 .endm
89 #endif
90
91 #endif  /* _ASM_UBICOM32_RANGE_PROTECT_ASM_H */