Skip to content

Commit e8b47e1

Browse files
murzinvRussell King
authored and
Russell King
committed
ARM: 8707/1: NOMMU: Update MPU accessors to use cp15 helpers
Currently, inline assembly for accessing to MPU's cp15 lacks volatile keyword which opens possibility to compiler to optimise such accesses as soon as we start using them more intensively. Rather than fixing inline asm, lets move MPU accessors to use cp15 helpers which do the right thing. Tested-by: Szemző András <[email protected]> Tested-by: Alexandre TORGUE <[email protected]> Tested-by: Benjamin Gaignard <[email protected]> Signed-off-by: Vladimir Murzin <[email protected]> Signed-off-by: Russell King <[email protected]>
1 parent 877ec11 commit e8b47e1

File tree

1 file changed

+26
-22
lines changed

1 file changed

+26
-22
lines changed

arch/arm/mm/pmsa-v7.c

+26-22
Original file line numberDiff line numberDiff line change
@@ -12,63 +12,67 @@
1212

1313
#include "mm.h"
1414

15+
#define DRBAR __ACCESS_CP15(c6, 0, c1, 0)
16+
#define IRBAR __ACCESS_CP15(c6, 0, c1, 1)
17+
#define DRSR __ACCESS_CP15(c6, 0, c1, 2)
18+
#define IRSR __ACCESS_CP15(c6, 0, c1, 3)
19+
#define DRACR __ACCESS_CP15(c6, 0, c1, 4)
20+
#define IRACR __ACCESS_CP15(c6, 0, c1, 5)
21+
#define RNGNR __ACCESS_CP15(c6, 0, c2, 0)
22+
1523
/* Region number */
16-
static void rgnr_write(u32 v)
24+
static inline void rgnr_write(u32 v)
1725
{
18-
asm("mcr p15, 0, %0, c6, c2, 0" : : "r" (v));
26+
write_sysreg(v, RNGNR);
1927
}
2028

2129
/* Data-side / unified region attributes */
2230

2331
/* Region access control register */
24-
static void dracr_write(u32 v)
32+
static inline void dracr_write(u32 v)
2533
{
26-
asm("mcr p15, 0, %0, c6, c1, 4" : : "r" (v));
34+
write_sysreg(v, DRACR);
2735
}
2836

2937
/* Region size register */
30-
static void drsr_write(u32 v)
38+
static inline void drsr_write(u32 v)
3139
{
32-
asm("mcr p15, 0, %0, c6, c1, 2" : : "r" (v));
40+
write_sysreg(v, DRSR);
3341
}
3442

3543
/* Region base address register */
36-
static void drbar_write(u32 v)
44+
static inline void drbar_write(u32 v)
3745
{
38-
asm("mcr p15, 0, %0, c6, c1, 0" : : "r" (v));
46+
write_sysreg(v, DRBAR);
3947
}
4048

41-
static u32 drbar_read(void)
49+
static inline u32 drbar_read(void)
4250
{
43-
u32 v;
44-
asm("mrc p15, 0, %0, c6, c1, 0" : "=r" (v));
45-
return v;
51+
return read_sysreg(DRBAR);
4652
}
4753
/* Optional instruction-side region attributes */
4854

4955
/* I-side Region access control register */
50-
static void iracr_write(u32 v)
56+
static inline void iracr_write(u32 v)
5157
{
52-
asm("mcr p15, 0, %0, c6, c1, 5" : : "r" (v));
58+
write_sysreg(v, IRACR);
5359
}
5460

5561
/* I-side Region size register */
56-
static void irsr_write(u32 v)
62+
static inline void irsr_write(u32 v)
5763
{
58-
asm("mcr p15, 0, %0, c6, c1, 3" : : "r" (v));
64+
write_sysreg(v, IRSR);
5965
}
6066

6167
/* I-side Region base address register */
62-
static void irbar_write(u32 v)
68+
static inline void irbar_write(u32 v)
6369
{
64-
asm("mcr p15, 0, %0, c6, c1, 1" : : "r" (v));
70+
write_sysreg(v, IRBAR);
6571
}
6672

67-
static unsigned long irbar_read(void)
73+
static inline u32 irbar_read(void)
6874
{
69-
unsigned long v;
70-
asm("mrc p15, 0, %0, c6, c1, 1" : "=r" (v));
71-
return v;
75+
return read_sysreg(IRBAR);
7276
}
7377

7478
/* MPU initialisation functions */

0 commit comments

Comments
 (0)